TSS Club Fair 2017 Problem A

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

In space, satellites are constantly bombarded with radiation from the sun. The radiation can cause software glitches by changing the stored memory on the satellite. To defend against this, programmers often run 3 copies of the program at once. This way, the satellite can check which copy of the program is different from the majority to detect errors, then copy over the correct solution from the other programs. However, this system is not fail-proof. Occasionally, 2 pieces of memory will be changed at the same time, producing 3 different results, in which case the computer will ignore the instruction.

Joey's satellite has N instructions on each of the 3 programs. Each of the 3 programs may have been damaged in different parts. Can you analyze the data and check which one is correct?

Input Specification

The first line will contain an integer N, indicating the number of instructions in each of the 3 programs.

The next N lines will contain 3 instructions separated by a space. Each instruction will consist of only English alphabet characters and numbers.

It is guaranteed N \le 10\,000.

Output Specification

In each of the next N lines, print the instruction which appears at least twice. If all 3 instructions are different, print ??? instead.

Sample Input 1

4
JOIN JOIN JOI
COMP CMP COMP
CLAB CLUB CLUB
TODAY TWODAY TOODAY

Sample Output 1

JOIN
COMP
CLUB
???

Sample Explanation 1

The 2 instances of JOIN overrule the 1 instance of JOI, making the final instruction JOIN.

You should really follow the instructions in this case.

Sample Input 2

3
DELSYS32 DELSYS33 DELSYS33
SHOTDOWN SHUTDOWN SHUTOFF
RESTART RESTART RESTART

Sample Output 2

DELSYS33
???
RESTART

Sample Explanation 2

Despite being clearly incorrect, the 2 copies of DELSYS33 overruled the instruction DELSYS32.

In the third instruction, all 3 programs agree with each other, so the output will be RESTART.


Comments

There are no comments at the moment.