TSS Club Fair 2017 Problem A
View as PDFIn 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  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, 
 pieces of memory will be changed at the same time, producing 
 different results, in which case the computer will ignore the instruction.
Joey's satellite has  instructions on each of the 
 programs. Each of the 
 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 , indicating the number of instructions in each of the 
 programs.
The next  lines will contain 
 instructions separated by a space. Each instruction will consist of only English alphabet characters and numbers.
It is guaranteed .
Output Specification
In each of the next  lines, print the instruction which appears at least twice. If all 
 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  instances of 
JOIN overrule the  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  copies of 
DELSYS33 overruled the instruction DELSYS32.
In the third instruction, all  programs agree with each other, so the output will be 
RESTART.
Comments