COCI '08 Contest 1 #2 Ptice

View as PDF

Submit solution

Points: 5
Time limit: 1.0s
Memory limit: 32M

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

Adrian, Bruno and Goran wanted to join the bird lovers' club. However, they did not know that all applicants must pass an entrance exam. The exam consists of N questions, each with three possible answers: A, B and C.

Unfortunately, they couldn't tell a bird from a whale so they are trying to guess the correct answers. Each of the three boys has a theory of what set of answers will work best:

Adrian claims that the best sequence is: A, B, C, A, B, C, A, B, C, A, B, C \cdots

Bruno is convinced that this is better: B, A, B, C, B, A, B, C, B, A, B, C \cdots

Goran laughs at them and will use this sequence: C, C, A, A, B, B, C, C, A, A, B, B \cdots

Write a program that, given the correct answers to the exam, determines who of the three was right – whose sequence contains the most correct answers.

Input Specification

The first line contains an integer N (1 \le N \le 100), the number of questions on the exam. The second line contains a string of N letters A, B and C. These are, in order, the correct answers to the questions in the exam.

Output Specification

On the first line, output M, the largest number of correct answers one of the three boys gets. After that, output the names of the boys (in alphabetical order) whose sequences result in M correct answers.

Sample Input 1


Sample Output 1


Sample Input 2


Sample Output 2



There are no comments at the moment.