QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#102575#6180. 滚动雪人游戏问题rzh123100 ✓60ms3732kbC++141.2kb2023-05-03 14:48:242023-05-03 14:48:28

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-03 14:48:28]
  • 评测
  • 测评结果:100
  • 用时:60ms
  • 内存:3732kb
  • [2023-05-03 14:48:24]
  • 提交

answer

#include <bits/stdc++.h>
#define debugf(...) fprintf(stderr,__VA_ARGS__)
#ifdef ONLINE_JUDGE
#define fprintf(...) (1)
#endif
using namespace std;
constexpr int N=10007,INF{0x3F3F3F3F};
int n,a[N];
char s[N];
int cc[3];
int ans,as{INF};
inline int step(int a){
    // static int cnt[3];
    // memcpy(cnt,cc,sizeof cc);
    int b{cc[(a+1)%3]},c{cc[(a+2)%3]};
    a=cc[a];
    int dd(min(b,c)),ss{0};
    b-=dd,c-=dd;
    ss+=dd;
    if(c) swap(b,c);
    // printf("%d,%d\n",b,c);
    if(!b) return ss;
    ss+=(b>>1),b-=((b>>1)<<1);
    if(b) return INF;
    return ss;
}
inline bool mian(){
    if(scanf("%d%s",&n,s+1)==EOF) return false;
    cc[0]=cc[1]=cc[2]=0;
    for(int i{1};i<=n;++i) a[i]=s[i]-65,++cc[a[i]];
    ans=-1,as=INF;
    for(int i:{0,1,2}){
        int s{step(i)};
        // printf("step %c=%d\n","ABC"[i],s);
        if(s<as) ans=i,as=s;
        else if(s==as) ans=-1;
        // printf("ans=%d,as=%d\n",ans,as);
    }
    printf("%c\n","NABC"[ans+1]);
    return true;
}
signed main(){
    // freopen("snow.in","r",stdin);
    // freopen("snow.out","w",stdout);
    while(mian());return 0;}

/*
 CCCCAB
 AAABBB
 AACBB
 ABBB

 ABBBBBBBBB
*/

詳細信息

Test #1:

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

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: 1ms
memory: 3528kb

input:

909
CBABACBACABBCBCCCABCAAABCBCAACCCCBABACCABCBABCBABCABBBCCBBCCCABBCBABCBCBABABAAACACBBCCCBBCBCBCCBCCCACCBBABCBACCACCCBBBCBBACCACBCCCCAACCCACCABACACCCCBACCCCBAACBABAAAAACABBCABBCACCAABBBCCBCBAABCAAAAACBCACBBBBCCCCAAABBBBCCCBBAAACCACBCACCCBACCBCACCACAACCBCACCACBACAACBBAACBACAACAACABBCBAABACBACCBACCB...

output:

C
A
B
B
N
A
C
A
B
A

result:

ok 10 lines

Test #3:

score: 10
Accepted
time: 42ms
memory: 3488kb

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: 45ms
memory: 3440kb

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: 20ms
memory: 3696kb

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: 25ms
memory: 3496kb

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: 43ms
memory: 3452kb

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: 36ms
memory: 3508kb

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: 3732kb

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: 60ms
memory: 3496kb

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