QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#102966 | #6180. 滚动雪人游戏问题 | 114514191981 | 100 ✓ | 355ms | 3576kb | C++14 | 4.5kb | 2023-05-03 20:44:18 | 2023-05-03 20:44:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
namespace Mikazuki_Munechika {
typedef long long ll;
typedef double db;
#define lowbit(a) a&-a
#define pii pair<int , int>
#define rep(i , a , n ) for(int i (a); i <= n ; i++)
#define per(i , a , n ) for(int i (n); i >= a ; i--)
#define aper(i , a) for(auto i : a)
#define pb push_back
#define mp make_pair
#define rs(x) x<<1|1
#define ls(x) x<<1
#define fi first
#define se second
#define YES puts("Yes")
#define NO puts("No")
#define gc getchar
#define pc putchar
#define size(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define vreturn return (void)
#define endl '\n'
#define doret(x) {x;return;}
#define brk(x) {x;break;}
#define ctn(x) {x;continue;}
#define reset(x, y) memset(x, y, sizeof(x))
#define BUG(x) cerr << #x << " = " << (x) << endl
#define BUGP(x) cout << #x << " = " << (x).first << ", " << (x).second << endl
int _;
ll __;
template<typename T , const T mod>
struct mint {
int v = 0;
mint(int _v = 0) : v(_v) {}
mint &operator += (const mint &X) { return (v += X.v) >= mod ? v -= mod : v, *this; }
mint &operator -= (const mint &X) { return (v += mod - X.v) >= mod ? v -= mod : v, *this; }
mint &operator *= (const mint &X) { return v = 1ll * v * X.v % mod, *this; }
mint &operator /= (const mint &X) { return *this *= X.inv(); }
mint qpow(int y) const { mint res = 1, x = *this; while (y) { if (y & 1) res *= x; x *= x; y >>= 1; } return res; }
mint inv() const { return qpow(mod - 2); }
friend mint operator + (const mint &A, const mint &B) { return mint(A) += B; }
friend mint operator - (const mint &A, const mint &B) { return mint(A) -= B; }
friend mint operator * (const mint &A, const mint &B) { return mint(A) *= B; }
friend mint operator / (const mint &A, const mint &B) { return mint(A) /= B; }
};
typedef mint<int , 998244353> mi9;
typedef mint<int , 1000000007> mi1;
template<typename T>inline T _gcd(T x, T y) {return y ? _gcd(y, x % y) : x;}
template<typename T>inline T abs(T x) {return x > 0 ? x : -x;}
template<typename T>inline T _abs(T x){return x = x > 0 ? x : -x;}
template<typename T>inline T _max(T &x, T y) {return x = x > y ? x : y;}
template<typename T>inline T _min(T &x, T y) {return x = x > y ? y : x;}
template<typename T>inline void _ck(T x) {vreturn (x ? YES : NO);}
template<typename T>inline T read(T &x) {T ch = gc(), ans = 0, fl = 1;for (; !isdigit(ch) ; ch = gc())if (ch == '-')fl = -1;for (; isdigit(ch) ; ch = gc())ans = (ans << 1) + (ans << 3) + (ch ^ 48);return x = fl * ans;}
template<typename T, typename ...Args>inline void read(T &x, Args &...args) {read(x);read(args...);}
template<typename T>inline void write(T x) {if(x < 0 ) {pc('-');x = -x;}static int sta[35];int top = 0;do {sta[top++] = x % 10, x /= 10;} while (x);while (top)pc(sta[--top] + 48);pc(' ');return ;}
template<typename T, typename ...Args>inline void write(T x, Args ...args) {write(x);write(args...);return ;}
template<typename T, typename ...Args>inline void write_(T x) {write(x);puts("");return ;}
template<typename T, typename ...Args>inline void write_(T x, Args ...args) {write(x);write(args...);puts("");return ;}
const int N6 = 1000100;
const int N5 = 100010;
const int _N5 = 500010;
const int _N6 = 5000100;
} using namespace Mikazuki_Munechika;
char ch[N6];
int A(int a , int b , int c){
if(!a && (!b || !c)){
return -1;
}
else if(!a){
return A(a + 1 , b - 1 , c - 1);
}else if(b && c){
return A(a + 1 , b - 1 , c - 1);
}else if(b){
return A(a - 1 , b - 1 , c + 1);
}else if(c){
return A(a - 1 , b + 1 , c - 1);
}else return a;
}
void solve() {
map<char,int> pm;
int n;
while(~scanf("%d" , &n)){
pm.clear();
cin >> (ch + 1);
rep(i ,1 , n){
pm[ch[i]] ++;
}
// cerr << pm['A'] << pm['B'] << pm['C'];
int ansa = A(pm['A'] , pm['B'] , pm['C']),
ansb = A(pm['B'] , pm['A'] , pm['C']),
ansc = A(pm['C'] , pm['A'] , pm['B']);
if(ansa == ansb && ansb == ansc) {
puts("N");
continue;
}
pair<ll,char> se[] = {{ansa , 'A'} , {ansb , 'B'} , {ansc , 'C'}};
sort(se , se + 3);
cout << se[2].second << "\n";
}
}
// #define LOCAL
signed main() {
#ifdef LOCAL
freopen("snow.in", "r", stdin);
freopen("snow.out", "w", stdout);
#endif
// int tt = read<int>(_);
// init();
clock_t c1 = clock();
// while (1) {
solve();
// }
cerr << "Time:" << clock() - c1 << "ms" << endl;
return 0;
}
详细
Test #1:
score: 10
Accepted
time: 5ms
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: 2ms
memory: 3500kb
input:
909 CBABACBACABBCBCCCABCAAABCBCAACCCCBABACCABCBABCBABCABBBCCBBCCCABBCBABCBCBABABAAACACBBCCCBBCBCBCCBCCCACCBBABCBACCACCCBBBCBBACCACBCCCCAACCCACCABACACCCCBACCCCBAACBABAAAAACABBCABBCACCAABBBCCBCBAABCAAAAACBCACBBBBCCCCAAABBBBCCCBBAAACCACBCACCCBACCBCACCACAACCBCACCACBACAACBBAACBACAACAACABBCBAABACBACCBACCB...
output:
C A B B N A C A B A
result:
ok 10 lines
Test #3:
score: 10
Accepted
time: 355ms
memory: 3576kb
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: 281ms
memory: 3508kb
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: 143ms
memory: 3508kb
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: 153ms
memory: 3520kb
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: 228ms
memory: 3516kb
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: 212ms
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: 229ms
memory: 3496kb
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: 352ms
memory: 3572kb
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