PDP-20 (2008) - Phase C' - 3 (code)

View as PDF

Submit solution

Points: 35 (partial)
Time limit: 20.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
C, C++, Java, Pascal, Python
Ancient Code

In a poster presented by two archaeology doctoral candidates during the 12th Panhellenic Conference of Informatics (EPY, Samos 2008), they presented an encrypted code from the Hellenistic period describing the operation of the Antikythera Mechanism. The colleagues of the Scientific Committee, in order to confirm this significant finding, reached out to top scientists in theoretical sciences. It was the will of the Scientific Committee for the text to pass successively through all experts in order to obtain the most authoritative opinion. Unfortunately, their relationships were not the best possible. Therefore, the text had to be transferred from specialist to specialist without being able to be done in any combination. For instance, the last person who will study the code must maintain communication with the first in order to be able to return it to where it started.

Problem:

Develop a program in one of the IOI languages that, after reading the correlations between scientists, will determine at least one possible transmission sequence. If this cannot happen, it will return 0. The text must return to the original recipient. (It is obvious that there may be more than one solution; any correct solution is acceptable).

Note 1: Each scientist has at least one colleague with whom they have good relationships. This relationship is mutual.

Note 2: The code cannot be studied (passed) more than once by the same scientist.

Input Files:

The input files named code.in are text files with the following structure: The first line contains an integer N (10 \le N \le 10.000), the number of correlations between scientists. The next N lines have the following structure. The first number M (1 \le M \le 1.000) on each line is the serial number of a scientist. The second number K (1 \le K \le 1.000) is also the serial number of a scientist with whom they have good relationships. This relationship is mutual. (The two numbers are separated by a space).

Output Files:

The output files named code.out are text files with the following structure. They have exactly \(Π\) lines Π (10 \le Π \le 1.000), where Π is the number of scientists. (So the code will only pass once through each scientist). The first line indicates the serial number of the scientist to whom the text will be delivered first. The last line indicates the serial number of the last scientist from whom the text will pass before returning to the first.

Example of Input - Output Files

STDIN (code.in)

11
1 2
1 3
1 10
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10

STDOUT (code.out)

1
2
3
4
5
6
7
8
9
10

(The output is indicative and NOT the only correct one)

Formatting: In the output, each line terminates with a newline character.
Maximum execution time: 20 sec.


Comments

There are no comments at the moment.