正在加载图片...
Problem a roublemakel Time limit. l second [after seeing that the room is on fire; Ted has a needle in his hand while holding the leg of a dead woman; Sara hasa bottle of champagne in her hand, and Juancho is smoking Man: Did they misbehave? Robert Rodr iges, The Misbehavers Every school class has its troublemakers those kids who can make the teachers life miserable. On his own, a troublemaker is manageable, but when you put certain pairs of troublemakers together in the same room, teaching a class becomes very hard. There are n kids in Mrs. Shaida's math class, and there are m pairs of troublemakers among them. The situation has gotten so bad that Mrs. Shaida has decided to split the class into two classes. Help her do it in such a way that the number of troublemaker pairs is reduced by at least a half. Input The first line of input gives the number of cases, N. n test cases follow. Each one starts with a line containing n(0<=n<=100)and m(0<m<5000) The next m lines will contain a pair of integers u and v meaning that when kids u and v are in the same room, they make a troublemaker pair. Kids are numbered from 1 to n Output For each test case, output one line containing Case #x: followed by L the number of kids who will be moved to a different class (in a different room). The next line should list those kids. The total number of troublemaker pairs in the two rooms must be at most m/2. If that is impossible, print Impossible. instead of L and an empty line afterward Sample Input Sample output Case #1: 1 34 23 121 Problem A Troublemakers Time Limit: 1 second [after seeing that the room is on fire; Ted has a needle in his hand while holding the leg of a dead woman; Sara has a bottle of champagne in her hand, and Juancho is smoking] Man: Did they misbehave? Robert Rodrigues, "The Misbehavers." Every school class has its troublemakers - those kids who can make the teacher's life miserable. On his own, a troublemaker is manageable, but when you put certain pairs of troublemakers together in the same room, teaching a class becomes very hard. There are n kids in Mrs. Shaida's math class, and there are m pairs of troublemakers among them. The situation has gotten so bad that Mrs. Shaida has decided to split the class into two classes. Help her do it in such a way that the number of troublemaker pairs is reduced by at least a half. Input The first line of input gives the number of cases, N. N test cases follow. Each one starts with a line containing n (0<=n<=100) and m (0<m<5000). The next m lines will contain a pair of integers u and v meaning that when kids u and v are in the same room, they make a troublemaker pair. Kids are numbered from 1 to n. Output For each test case, output one line containing "Case #x:" followed by L - the number of kids who will be moved to a different class (in a different room). The next line should list those kids. The total number of troublemaker pairs in the two rooms must be at most m/2. If that is impossible, print "Impossible." instead of L and an empty line afterwards. Sample Input Sample Output 2 4 3 1 2 2 3 Case #1: 1 1 3 4 Case #2: 2 1 2
向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有