# include <cstdio> int load_and_count_one_degree_nodes( int nodes_total ) { int one_degree_nodes_total = 0; for ( int i = 0; i < nodes_total; i ++ ) { int current_node_degree; scanf( "%d", & current_node_degree ); if ( current_node_degree == 1 ) { one_degree_nodes_total ++; } } return one_degree_nodes_total; } void print_solution( int one_degree_nodes_total ) { int nodes_to_change; if ( one_degree_nodes_total == 0 ) { nodes_to_change = 2; } if ( one_degree_nodes_total == 1 ) { nodes_to_change = 1; } if ( one_degree_nodes_total >= 2 ) { nodes_to_change = 0; } printf( "%d\n", nodes_to_change ); printf( "2\n" ); printf( "1 2\n" ); } int main() { int nodes_total; scanf( "%d", & nodes_total ); int one_degree_nodes_total = load_and_count_one_degree_nodes( nodes_total ); print_solution( one_degree_nodes_total ); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | # include <cstdio> int load_and_count_one_degree_nodes( int nodes_total ) { int one_degree_nodes_total = 0; for ( int i = 0; i < nodes_total; i ++ ) { int current_node_degree; scanf( "%d", & current_node_degree ); if ( current_node_degree == 1 ) { one_degree_nodes_total ++; } } return one_degree_nodes_total; } void print_solution( int one_degree_nodes_total ) { int nodes_to_change; if ( one_degree_nodes_total == 0 ) { nodes_to_change = 2; } if ( one_degree_nodes_total == 1 ) { nodes_to_change = 1; } if ( one_degree_nodes_total >= 2 ) { nodes_to_change = 0; } printf( "%d\n", nodes_to_change ); printf( "2\n" ); printf( "1 2\n" ); } int main() { int nodes_total; scanf( "%d", & nodes_total ); int one_degree_nodes_total = load_and_count_one_degree_nodes( nodes_total ); print_solution( one_degree_nodes_total ); return 0; } |