## COCI '08 Contest 1 #2 Ptice

View as PDF

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

Problem type

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 questions, each with three possible answers: , and .

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:

Bruno is convinced that this is better:

Goran laughs at them and will use this sequence:

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 , the number of questions on the exam. The second line contains a string of 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 , 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 correct answers.

#### Sample Input 1

5
BAACC

#### Sample Output 1

3
Bruno

#### Sample Input 2

9
AAAABBBBB

#### Sample Output 2

4
Bruno
Goran

• commented on Dec. 3, 2022, 11:00 a.m.

remember the order in which you print the names also matters!

• commented on July 29, 2022, 7:44 p.m.

Since the original data were weak, an additional two test cases were added, and all submissions were rejudged.

• commented on July 25, 2022, 9:16 a.m.

My code passes 9/10 cases though and I am not sure what the last case is the clipped output was "1 Adrian Bruno" I am very confused

• commented on June 17, 2022, 6:00 p.m.

I'm sure there is a much better way to do this, but at least it actually worked the way I did it.

• commented on May 1, 2022, 9:48 p.m.

The main trick is to create the answer key sequence for each person.

• commented on June 11, 2022, 3:43 p.m.

You can use division with remainder.