959C.md (2943B)
1 Source: https://codeforces.com/problemset/problem/959/C 2 3 C. Mahmoud and Ehab and the wrong algorithm 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 Mahmoud was trying to solve the vertex cover problem on trees. The problem statement is: 22 23 Given an undirected tree consisting of *n* nodes, find the minimum number of vertices that cover all the edges. Formally, we need to find a set of vertices such that for each edge (*u*, *v*) that belongs to the tree, either *u* is in the set, or *v* is in the set, or both are in the set. Mahmoud has found the following algorithm: 24 25 * Root the tree at node 1. 26 * Count the number of nodes at an even depth. Let it be *evenCnt*. 27 * Count the number of nodes at an odd depth. Let it be *oddCnt*. 28 * The answer is the minimum between *evenCnt* and *oddCnt*. 29 30 The depth of a node in a tree is the number of edges in the shortest path between this node and the root. The depth of the root is 0. 31 32 Ehab told Mahmoud that this algorithm is wrong, but he didn't believe because he had tested his algorithm against many trees and it worked, so Ehab asked you to find 2 trees consisting of *n* nodes. The algorithm should find an incorrect answer for the first tree and a correct answer for the second one. 33 34 Input 35 36 The only line contains an integer *n* (2 ≤ *n* ≤ 105), the number of nodes in the desired trees. 37 38 Output 39 40 The output should consist of 2 independent sections, each containing a tree. The algorithm should find an incorrect answer for the tree in the first section and a correct answer for the tree in the second. If a tree doesn't exist for some section, output "-1" (without quotes) for that section only. 41 42 If the answer for a section exists, it should contain *n* - 1 lines, each containing 2 space-separated integers *u* and *v* (1 ≤ *u*, *v* ≤ *n*), which means that there's an undirected edge between node *u* and node *v*. If the given graph isn't a tree or it doesn't follow the format, you'll receive wrong answer verdict. 43 44 If there are multiple answers, you can print any of them. 45 46 Examples 47 48 Input 49 50 ``` 51 2 52 ``` 53 54 Output 55 56 ``` 57 -1 58 1 2 59 ``` 60 61 Input 62 63 ``` 64 8 65 ``` 66 67 Output 68 69 ``` 70 1 2 71 1 3 72 2 4 73 2 5 74 3 6 75 4 7 76 4 8 77 1 2 78 1 3 79 2 4 80 2 5 81 2 6 82 3 7 83 6 8 84 ``` 85 86 Note 87 88 In the first sample, there is only 1 tree with 2 nodes (node 1 connected to node 2). The algorithm will produce a correct answer in it so we printed - 1 in the first section, but notice that we printed this tree in the second section. 89 90 In the second sample: 91 92 In the first tree, the algorithm will find an answer with 4 nodes, while there exists an answer with 3 nodes like this:  In the second tree, the algorithm will find an answer with 3 nodes which is correct: 