#P14733. [ICPC 2022 Seoul R] Two Choreographies
[ICPC 2022 Seoul R] Two Choreographies
题目描述
Somim and Eunjoo are famous dancers and very talented choreographers, but they haven't won a contest recently. To win the contest this year, they are trying to help each other to make new choreographies. Actually, nobody has tried smoothly appending static motions, and they are going to give it a try for the first time!
Somim and Eunjoo want to make two choreographies consisting of static motions for each of them. They have a good understanding of how to smoothly append static motions, and they concluded that exactly unordered pairs of static motions are enough for them to perform freely. The order of static motions in a pair does not matter, i.e., if motion can be appended after motion , then can also be appended after .
The choreographies which Somim and Eunjoo want to perform are as follows. The two choreographies last for the same amount of time, which means that each one should consist of the same number of static motions. Each choreography should end at its first static motion. More precisely, two choreographies and are sequences of distinct static motions, and where and . For the entertainment of the audience, and should be different, that is, there should be some which in is not equal to any of in for . (For example, and are different but and are not.) Also, the audience easily gets bored, so the choreography should not be too short, and contain at least 3 distinct static motions, that is, .
For this, you are given unordered pairs of static motions from distinct static motions that two dancers can perform. For a pair where , one of and can appear after the other in the sequence; there is no specific order between them. You should write a program to find two different choreographies and of the same length such that , for any , and and .
输入格式
Your program is to read from standard input. The input starts with a line containing a single integer, (), where is the number of static motions two dancers can represent. Each static motion is numbered as an integer from 1 to . The following lines represent unordered pairs of static motions, . Each line contains two distinct integers representing two static motions of a pair of . Note that no two pairs in are identical.
输出格式
Your program is to write to standard output. If you cannot find two choreographies of static motions, then print . If not, you should print exactly three lines. The first line contains an integer which is the number of distinct static motions in each choreography. The second line contains exactly integers, separated by a space, each representing a choreography of the static motions in order. The last repeated motion should be omitted. The third line contains exactly integers representing the other choreography.
4
1 2
1 3
1 4
2 3
2 4
3
1 2 3
1 2 4
5
1 2
1 3
1 4
1 5
2 3
2 5
3 4
3
1 2 3
1 3 4
7
1 2
3 4
5 6
5 2
3 1
6 1
4 2
4 5
2 6
3 6
1 5
4
6 1 5 2
4 2 1 3