QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#93769#6180. 滚动雪人游戏问题Renshey100 ✓67ms3628kbC++23739b2023-04-02 10:33:102023-04-02 10:33:13

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-02 10:33:13]
  • 评测
  • 测评结果:100
  • 用时:67ms
  • 内存:3628kb
  • [2023-04-02 10:33:10]
  • 提交

answer

#include <bits/stdc++.h>
int n, cnt[3]; char S[10010];
inline int solve (int x)
{
    int y = (x + 1) % 3, z = (y + 1) % 3, cx = cnt[x], cy = cnt[y], cz = cnt[z];
    if (!cx and (!cy or !cz)) return 1 << 30;
    return ((cy + cz) & 1) ? (1 << 30) : std::max(cy, cz);
}
signed main ()
{
    while (~scanf("%d", &n))
    {
        scanf("%s", S); cnt[0] = cnt[1] = cnt[2] = 0;
        for (int i = 0; i < n; i++) cnt[S[i] - 'A']++;
        int w[3] = {solve(0), solve(1), solve(2)};
        int ans = std::min({w[0], w[1], w[2]}); std::vector<char> Ans;
        for (int i = 0; i < 3; i++) if (ans == w[i]) Ans.push_back('A' + i);
        putchar((int)Ans.size() > 1 ? 'N' : Ans[0]); putchar('\n');
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 10
Accepted
time: 2ms
memory: 3512kb

input:

370
AAAABCCBBBACAABCAAAABBCCABACCBCCCCAAAAABBBCCACCBBBCBAABCABAABBCBAAAAABACBCAAAABBABBBBBBABCBBCCCACACABCCBBBABBBCACCBBAAABCACCACCABCAACBCCBBAABABCBCAAACABABCAAABCACCACCABCBCBCCCCCBCBCBACCCBACBCBBCBCCABCBABBCCBBAACCBBBCACBCBABBCABAABCCABCABBBABAABACACBBABBBCCACABCCCACABACCBBBBABABCBBBABABCCABAACAAB...

output:

B
C
C
B
C
A
A
B
A
A
A
A
A
C
A
B
A
A
A
C
A
B
A
A
B
N
C
B
B
C
B
B
A
C
A
B
A
C
B
N
A
B
B
C
B
C
C
B
A
B
A
B
A
A
B
A
C
C
A
A
C
B
A
C
C
B
A
B
C
C
B
B
B
A
A
B
B
A
C
A
B
C
N
B
A
B
B
B
B
C
C
B
C
B
B
B
C
B
C
C
C
N
B
A
A
A
A
A
A
A
C
C
C
C
A
C
A
B
B
B
A
A
B
A
C

result:

ok 125 lines

Test #2:

score: 10
Accepted
time: 2ms
memory: 3492kb

input:

909
CBABACBACABBCBCCCABCAAABCBCAACCCCBABACCABCBABCBABCABBBCCBBCCCABBCBABCBCBABABAAACACBBCCCBBCBCBCCBCCCACCBBABCBACCACCCBBBCBBACCACBCCCCAACCCACCABACACCCCBACCCCBAACBABAAAAACABBCABBCACCAABBBCCBCBAABCAAAAACBCACBBBBCCCCAAABBBBCCCBBAAACCACBCACCCBACCBCACCACAACCBCACCACBACAACBBAACBACAACAACABBCBAABACBACCBACCB...

output:

C
A
B
B
N
A
C
A
B
A

result:

ok 10 lines

Test #3:

score: 10
Accepted
time: 50ms
memory: 3504kb

input:

1272
BACAAACACABABACACAAABCCCCCABCBCBBCACBABAAAACCAABCBBCCABBCABCAABBBAABCBBBBCBABACACCCCBCCBCBBBCCBABBAABAABCAABBAAAABBCBAAAACBCBBBAAAABBBCBCBACCBBCCCCCBBCBAACBBBBCACCCABBCACCBABCBACBBBACAABCCBACCCBABCBAACCBCCCCBCCCCCBAACCCBBBBCCBBAAABBCBBBAABBAACBAAACAABBBBBACBBCBBBACCBCCAACCACCBAACCBBBACBBBAACBCB...

output:

C
C
C
C
A
B
B
B
B
B
A
B
B
A
A
A
B
A
B
A
B
A
C
B
A
B
C
A
C
B
C
C
C
A
C
C
A
A
B
A
A
A
A
A
A
C
C
C
C
B
C
C
B
A
A
A
N
C
A
A
A
A
B
A
C
C
B
B
A
A
C
B
B
A
A
C
B
A
B
C
B
A
C
A
A
A
A
A
B
B
A
C
A
A
C
B
A
C
B
B
B
A
B
A
A
C
C
C
B
B
B
B
C
B
C
B
C
B
A
C
B
B
B
C
C
C
A
C
B
A
A
B
C
A
B
B
A
C
A
A
A
A
B
C
B
A
C
C
A
C
...

result:

ok 2750 lines

Test #4:

score: 10
Accepted
time: 32ms
memory: 3588kb

input:

9694
ACABACCAAABAABACBBACACBCBBCCACBACAAACCBCBCCCCBAACACCACCABBCAABCCBCCBBCABBCBAAACABABBAAAABBCBABCCBBBABACCACABACCACCABBAABACAAABABCCAABBBCAAABCBCAACABBCCCABAAAAABBCCCAAABAABBCACABABCCBAACCBCABABBABAABBBABBACCBAAABCABAABCCBAAAACABBCAABCBBAABABCBBCCBCBBBBCCBCCAABBCAAAACABAABBBACACACBAACABAACACACCBB...

output:

A
C
C
B
A
C
A
B
B
B
A
A
B
B
B
B
C
A
B
B
A
B
C
B
C
B
C
C
B
C
A
C
A
B
C
C
C
C
A
A
A
A
A
C
A
B
A
B
B
B
B
A
A
A
A
C
B
B
B
A
B
B
A
B
C
C
C
A
B
A
A
B
A
A
A
C
B
B
B
B
A
B
B
A
C
B
C
C
B
B
C
B
C
B
A
A
A
C
A
A
B
B
C
B
B
B
B
B
A
B
C
B
A
C
C
B
B
C
A
A
B
A
A
B
A
C
C
A
B
A
C
A
B
A
A
A
C
C
A
A
C
C
C
C
A
C
A
A
C
A
...

result:

ok 2302 lines

Test #5:

score: 10
Accepted
time: 17ms
memory: 3532kb

input:

5385
ABCAABBBACAAACCCBCACCBBACAACCBBBBCCABCCBACBBCCACAAAACBACABCCBAACCBCCABCBBAABAAACBAABABBCBCBCCCBBBBCABBCCBCACBAABABBBAACACCBCABCBCBBCCBABCCBBBCBCCBCBCBCBAAAACCAABBBCCBAACCACBAAACCBBAAABCABACBBABAACACCAACCACBAABBBAAABBCCAACBAACCBABABBACABCCCACCCACBBCACAABABCACAAAAACABACCCBBBBCCCBABACABAACCCCCACAA...

output:

A
C
A
C
C
C
C
A
C
C
B
C
C
A
C
A
B
B
C
B
C
C
C
C
A
B
A
A
B
C
C
A
B
C
C
C
A
C
A
A
B
B
B
B
C
B
C
C
B
C
B
A
A
C
B
B
C
B
A
A
C
B
C
A
C
B
C
C
B
B
A
A
B
A
C
C
C
A
A
A
A
C
C
A
C
A
C
C
C
A
C
A
C
A
C
A
C
B
B
C
B
B
B
A
B
C
A
A
C
B
C
C
B
C
A
A
C
C
A
A
A
A
A
A
C
A
C
B
B
C
A
B
C
A
C
B
C
C
C
B
A
B
C
B
A
A
B
B
C
A
...

result:

ok 967 lines

Test #6:

score: 10
Accepted
time: 19ms
memory: 3464kb

input:

7790
CABACACCCAAACBBABAAABCBCBCBCBACAACBCBBBCABACBACBBAAACBBCACABABBCBBBCCABBAAACBACABCCCCBBAACCCBABCBCBCAAAAACCBBBCABCBCCACBACCBABAABAABCBCBBBABBBCBABAACBCBACACBCABCBCBBACBBCCCCCACAAACABBCBACCABBCBACCABBBCCCACBCBACAAACABCAACBCABCBCCCACAAAACBBBACCAAABCBAABCACBCCABBAAACACCCBABABBBCABBACBBBBACBBBBBCAA...

output:

A
B
A
A
C
B
A
C
C
B
A
C
A
B
C
C
B
A
B
A
A
C
C
A
C
A
B
B
A
B
B
B
C
B
C
C
C
A
A
C
C
B
C
C
C
A
C
B
N
C
A
B
B
B
A
B
B
B
A
A
A
B
B
B
B
C
C
C
B
B
B
A
A
C
C
C
A
A
A
B
A
A
A
C
B
C
B
C
B
C
B
B
C
B
B
B
B
C
A
B
C
A
B
B
B
A
C
C
B
A
A
B
C
B
A
B
B
B
B
A
B
A
C
B
B
B
B
B
A
A
C
B
C
A
N
B
B
C
C
A
A
N
A
A
C
C
A
A
B
C
...

result:

ok 1130 lines

Test #7:

score: 10
Accepted
time: 33ms
memory: 3584kb

input:

8580
BACCABCCBABBBCCBBACACACBBBABBCABCAACBCBBBBABBAAAACCACABCCBABCBCCBACCCBCBCCABCCCCBCCBCACBBACCCACBCCBCCAACBBCBABCABCCABCBCCBBAAACCACABCCCABABAACBCBCAAAAACCCCBABBAABBBAACBCCCCABBBBCCABCCABCCCABABAABBCCAABBBBBAAACAAACCCAABBACABACABACCACBCBBBACACCCAACCBBBAACABCCBBACBCCACABCBACCCCABCCCBCAAABAABBAACCB...

output:

A
C
C
B
B
B
B
B
C
B
C
A
C
C
C
C
B
B
B
B
B
C
B
A
C
C
C
B
B
B
B
A
B
A
A
B
B
N
C
A
C
A
B
A
C
C
A
A
C
A
B
B
A
C
C
B
C
B
A
B
B
A
A
C
C
C
B
C
B
A
A
B
A
C
B
A
B
A
C
B
A
C
C
C
C
A
C
N
B
A
B
A
B
B
A
C
C
C
C
B
C
C
C
A
A
B
B
A
C
A
B
A
C
A
C
B
A
A
A
A
C
A
B
A
B
B
B
A
B
B
A
A
C
A
C
C
C
C
C
C
B
C
C
B
C
A
A
A
C
C
...

result:

ok 1537 lines

Test #8:

score: 10
Accepted
time: 19ms
memory: 3628kb

input:

5296
BCAABBBCABBCBCCBAAAABABBBACACACABBACACBACCCBBACCCCCCAAACCBCAABCBACBCCACABACCABBBBBCCACCBCBBCCCACAABACACAAACABCBCABCBCCABCCACACCCCBBACAACCBABBCBBBBABACABBBACBABCBBAAABAAACBACCBCCCBCCAACBACABCCCBAAACBAABAACBBCBACACCABCBCACACCCAACACACBCBCBBCCBBBBBCCBCCCAACABBAABAACBCACBACBCACBAACAAAAAACBABABBCBAAC...

output:

C
B
A
A
C
A
B
C
C
C
B
A
C
B
B
C
C
C
B
B
B
C
B
C
B
B
C
C
B
A
C
A
A
A
B
B
C
B
C
B
A
A
C
A
N
B
A
A
B
A
C
A
C
B
B
C
C
B
B
C
A
B
B
B
B
C
C
A
B
C
C
A
B
A
A
B
B
A
A
B
A
B
A
B
C
B
B
A
B
A
B
B
A
A
C
C
A
C
N
A
C
B
A
C
B
B
C
N
B
B
B
B
B
A
A
B
C
B
B
A
C
C
C
A
A
A
C
C
B
C
A
C
A
B
A
B
C
C
A
C
A
A
A
C
A
B
A
B
C
C
...

result:

ok 1565 lines

Test #9:

score: 10
Accepted
time: 38ms
memory: 3456kb

input:

5195
AACCCCACABACBAAAACBAABBACAAAABBBBCBAAAABCCCACAABCBCAAABBBABBCCABABCCABBCBACBBBCBCCBCBCABABCAABACBAAACBBBABCBBCBCBAABACCABBBCBBBBCBACCCCCBCAAACACAAACBAAAACCCAABCCCCACAABCCCAABABAABAAABCBCCAAAACBAABBBACBBACCCCCABBBAABACCCAACABBABBAACBBBBBBCABBBACCCACCBBBACCABAACCBABAACBBCCBCABCBABCBABBCCAABBAACCB...

output:

A
C
A
A
B
B
B
B
B
A
N
C
A
C
C
B
A
B
B
B
A
C
C
A
C
C
A
C
C
B
A
C
A
C
C
A
C
B
A
C
B
B
A
A
A
B
C
C
B
C
A
C
A
A
A
C
B
B
C
C
A
A
B
B
C
A
B
A
A
A
B
B
A
A
A
B
C
B
A
C
A
C
C
C
B
B
A
B
C
C
C
A
B
C
C
B
B
C
C
C
C
A
A
A
C
A
A
B
B
C
B
B
A
A
C
B
C
C
A
C
B
A
C
C
B
B
A
C
C
A
A
C
A
A
B
B
A
B
B
C
B
C
A
C
B
A
B
B
A
C
...

result:

ok 1895 lines

Test #10:

score: 10
Accepted
time: 67ms
memory: 3524kb

input:

8526
BACBCCAACBBABABACBBBCBCAACCBBBCBABBBCBAABCACACCBBBAACCAABACBBCBAACCBABBAACBACBACCBCCAAABCAAAAAABBCABCBABBCCBBBBCCAACBCBABBBBBAACACBCBAAAABBBABBBAABBBBCBABBABBBAACCAABAACAACBCBBCBCABACCCBBAABCABCCBCAACCCCABBCCBBACBABABCCACAABCACBABACBCBCACBBAABCBAABBCABBCBABACCACCBBBACBCBCACAABBBACACBBBABCABAACB...

output:

A
B
B
B
A
C
B
B
C
C
C
C
A
C
A
C
B
C
C
B
C
C
A
B
B
B
A
C
C
B
A
B
B
A
C
C
B
N
C
C
B
C
C
B
B
A
C
B
C
C
A
B
B
A
B
B
A
B
A
A
B
A
A
B
C
C
A
A
C
C
B
C
C
C
B
C
B
B
B
C
C
B
B
C
A
B
A
A
A
B
B
A
C
C
B
C
C
B
A
A
C
C
C
B
C
N
C
B
B
B
C
B
C
C
B
B
B
C
B
B
C
C
B
C
C
A
C
A
B
B
B
C
C
A
B
A
A
C
A
A
C
A
B
C
C
C
B
A
A
A
...

result:

ok 2796 lines