DMOPC '17 Contest 4 P5 - Revised IOI

View as PDF

Submit solution


Points: 12
Time limit: 1.0s
Memory limit: 256M

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

The IOI has decided to change its format! Now, it will be composed of N true or false questions about the socioeconomic factors affecting occupations in computer science. Shortly after the contest, Team Canada's four members are checking their answers with each other. Their answers will be represented as four strings of length N composed of Ts and Fs. The score of a member is the number of correct answers minus the number of wrong answers (no blanks are allowed). The score of a team is the sum of the squares of the members' scores.

For example, if N=5 and Team Canada's members answered TFFTF, TTFTT, FTTTF, and TFFFF, and the answer key were TTTTT, then the members' scores would be -1, 3, 1, -3 and the team's score would be (-1)^2+(3)^2+(1)^2+(-3)^2=20.

The contestants have not yet been marked as you have stolen the answer key! You plan to adjust the answer key. What answer key will maximize Team Canada's score?

If there are multiple valid answer keys, any of them will be accepted.

Constraints

1\le N \le 10^6

Input Specification

The first line of input will contain a single integer N. The next four lines of input will each contain a string of length N composed of Ts and Fs representing the answers of each of Team Canada's members.

Output Specification

Output a single string of length N composed of Ts and Fs. This string should represent an answer key which maximizes Team Canada's score.

Sample Input 1

5
TFFTF
TTFTT
FTTTF
TFFFF

Sample Output 1

TFFFF

Sample Input 2

8
TTTTTTTT
TTTTTTTT
TTTTTTTT
FFFFFFFF

Sample Output 2

FFFFFFFF

Comments

There are no comments at the moment.