A1147 | [COCI-2008_2009-contest1]#4 PTICE
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
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 ...
Bruno is convinced that this is better: B, A, B, C, B, A, B, C, B, A, B, C ...
Goran laughs at them and will use this sequence: C, C, A, A, B, B, C, C, A, A, B, B ...
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.
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 ...
Bruno is convinced that this is better: B, A, B, C, B, A, B, C, B, A, B, C ...
Goran laughs at them and will use this sequence: C, C, A, A, B, B, C, C, A, A, B, B ...
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.
输入格式
The first line contains an integer N (1 ≤ N ≤ 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.
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.
输出格式
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.
After that, output the names of the boys (in alphabetical order) whose sequences result in M correct answers.
输入输出样例
输入 #1
5 BAACC
输出 #1
3 Bruno
输入 #2
9 AAAABBBBB
输出 #2
4 Adrian Bruno Goran
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted