TSS Club Fair 2017 Problem A

View as PDF

Submit solution

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

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

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


  • 7
    kobortor  commented on Sept. 20, 2017, 12:13 p.m.

    Lollipops will be given at the first computer club meeting to those who solved the problem.


    • -3
      Super_User  commented on Jan. 24, 2020, 6:10 p.m.

      What if you aren't in the computer club?