QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#120928 | #4327. Šeširi | abs998244353# | 7 | 92ms | 63124kb | C++17 | 1.6kb | 2023-07-07 12:44:21 | 2024-07-04 00:28:53 |
Judging History
answer
#include <cstdio>
using namespace std;
int read(){
char c=getchar();int x=0;
while(c<48||c>57) c=getchar();
do x=(x<<1)+(x<<3)+(c^48),c=getchar();
while(c>=48&&c<=57);
return x;
}
const int N=(1<<19)|3,M=5000003;
int hd[N],ver[M],nxt[M],tot=1;
int cur[N];
bool del[M];
int n;
int stk[M],tp;
bool deg[N];
void add(int u,int v){
deg[v]^=1;
nxt[++tot]=hd[u];hd[u]=tot;ver[tot]=v;
}
void path(int u){
while(del[cur[u]>>1]) cur[u]=nxt[cur[u]];
if(cur[u]){
del[cur[u]>>1]=1;
path(ver[cur[u]]);
stk[++tp]=cur[u]>>1;
cur[u]=nxt[cur[u]];
}
else deg[u]^=1;
//printf("%d ",u);
}
void dfs(int u){
for(int i=cur[u];i;i=cur[u]){
cur[u]=nxt[i];
if(del[i>>1]) continue;
del[i>>1]=1;
dfs(ver[i]);
stk[++tp]=i>>1;
}
//printf("%d ",u);
}
int id[18][1<<17];
bool res[M];
int que[N],tl;
int main(){
n=read();
for(int i=0;i<n;++i)
for(int s=0;s<(1<<(n-1));++s){
int msk=s&((1<<i)-1);
int u=((s^msk)<<1)|msk;
int v=u|(1<<i)|(1<<n);
add(u,v);add(v,u);
id[i][s]=tot>>1;
}
for(int i=0;i<(1<<(n+1));++i){
cur[i]=hd[i];
if(deg[i]) que[++tl]=i;
}
for(int pos=1;pos<=tl;++pos){
int u=que[pos];
if(deg[u]){
deg[u]^=1;
path(u);
//putchar('\n');
int par=(u>(1<<n));
while(tp){
res[stk[tp--]]=par;
par^=1;
}
}
}
for(int i=0;i<(1<<(n+1));++i){
dfs(i);
//putchar('\n');
int par=(i<(1<<n));
while(tp){
res[stk[tp--]]=par;
par^=1;
}
}
for(int i=0;i<n;++i){
for(int s=0;s<(1<<(n-1));++s)
if(res[id[i][s]]) putchar('C');
else putchar('B');
putchar('\n');
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 17608kb
input:
4
output:
CBCCCBCC CCBBCBBB BBCBBBCC BBBBCCBB
result:
wrong answer your plan fails on CCCC
Subtask #2:
score: 7
Accepted
Test #2:
score: 7
Accepted
time: 2ms
memory: 17684kb
input:
5
output:
CCBBCBCCBBBBCCBB CBCBBCBBCCBCBBCC BCBCCBBCBCCBBCBB BBCBBCCBCBBCCBCC BCBBCBBCBCCBBCBB
result:
ok good plan!
Subtask #3:
score: 0
Wrong Answer
Test #3:
score: 0
Wrong Answer
time: 0ms
memory: 17664kb
input:
6
output:
CBBCCCBCCBCCCBCCCBCCCCCBCBCCCBCC CCBBCCBBBBBBCCBBCBBBBBCBCCBBCBBB CCCBBBBBCCCCBBCBBBCCBBBBBBCBBBCC BBBBCCCCBBBBBBBBCCCCCCCBBBBBCCBB BBCCBBBBCCCCCCCBBBBBBBBBCCCCBBCC BBBBCCBBBBBBBBBBCCCCCCCCBBBBCCBB
result:
wrong answer your plan fails on CCCBBB
Subtask #4:
score: 0
Wrong Answer
Test #4:
score: 0
Wrong Answer
time: 0ms
memory: 19756kb
input:
7
output:
CCBBCCCCBBCBCCBBCCBCCCBBCCBBBBCCBBCBCCBBCCBBCBBBCBCBBBCCCBBBCCBB CBCBBBBBCCBCCBCCBCBBBBCCCBCBCCBBCCBCBBCCBBCCBCBCCCBBCCBBBCBCBBCC CCBCCBBCBCCBBCBBCBBCBCBBBCBCCBBCBCBBBCBBBCBBBCCBBBCCBBBCCCCBBCBB BBCCBCCBCBBCBBCBBCCBCCBCBCBBBCCBCBBCCBCCBBCBCBBCBCBBCCCBBBBCCBCC BCBBCBBCBCCBCCBCCBBCBCCBBCCBCBBCBCCBCBBC...
result:
wrong answer your plan fails on CCCCBBB
Subtask #5:
score: 0
Wrong Answer
Test #5:
score: 0
Wrong Answer
time: 1ms
memory: 19712kb
input:
8
output:
CBBCBBBCBCCBCBBCCBCCCCCBCBBBCBBCCBCBCCCBCBCCCBCCCBBCCCBCCBCCCBCCCBCCCBCBCBCCCBCCCBCCCBCCCBCCCCCBCBBCCCBCCBCCCBCCCBCCCCCBCBCCCBCC CCBBCCBBBBCCCCBBBBBBBBCCCCBBCBBBBBCCBBBBCCBBCBBBCCBBCCBBBBBBCCBBCBBBCCCBCCBBCBBBCCBBCBBBCBBBBBCBCCBBCCBBBBBBCCBBCBBBBBCBCCBBCBBB CCCBBBBBCCBBCCCBBBCCBBBBCCBBBBBCCCCCBBBCBB...
result:
wrong answer your plan fails on CCCCBBBB
Subtask #6:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 1ms
memory: 19728kb
input:
9
output:
CCBBCBCCBCCBCCBBCCCCCCBBCCBBBCCCBCBBCCBBCCBCCBCBCBCBBBCCCBCBCCBBCCBCCCBBCBCBBCBCCBCBBBCCCBBBCCBBCCBBCCCBBBCCCBCBBCBCCCBBCCBBBBCCBCCBCCBBCCBBCBCBCBCBBBCCCBBBCCBBCCBBCBCBBBBCCBCBCBCBCCBBCCBBCBBBCBCBBCCCCBCBCCBBBCBCCCBBCCBBCBCCCBCBCCBBCCBBBBBBCBCBBBCCCBBBCCBB CBCBBCBBCBCCCBCCBCBBBBCCCBCBCBBBCCBCBBCCCBC...
result:
wrong answer your plan fails on CCCCBBBBB
Subtask #7:
score: 0
Wrong Answer
Test #7:
score: 0
Wrong Answer
time: 0ms
memory: 19756kb
input:
10
output:
CBBCBBBCBCCBCBCCBCCBCCBBCBBBCBBCBBCBCBCCCBCCCBCBCBBCBBBCBCCBCBBCBBCBCBCBCBCCCBCCCBCCCBBBCBCCCCCBCBBCCCBCBCCBCBBBCBCCCBCBCBBBCBBCCCCBCCCBCBCCCBCBCBCCCBCCCBCBCCCBCBBCCCBCCBCCCBCCCBCCCCCBCBCCCBCCCBBCBBBCBCCBCBBCCBCCCCCBCBBBCBBCCBCBCCCBCBCCCBCCCBBCCCBCCBCCCBCCCBCBCBCBCBCCCBCCCBCCBBCBCBCCCBCBCBBCCCBCCBCC...
result:
wrong answer your plan fails on CCCCBBBBBB
Subtask #8:
score: 0
Wrong Answer
Test #8:
score: 0
Wrong Answer
time: 0ms
memory: 19848kb
input:
11
output:
CCBBCBCCBBCBCCBBCBBCBCBBCCBBBCCCBCCBCCBBCCBCCCCBCBCBBBCCCCCBCCBBCCBCBCBBCBCCBCCCCBCBBBCCCBCBCCBBCCBBCBCBBCCCCBCBBCCCCCBBCCBBBCCCBCBBCCBBCCBBCCBBCBCBBBCCCBBBCCBBCCBBCBCBBBBCCBCBCCBBCCBBCCBCCBCBCBCBBCCCCCCBCCBBBBCCCCBBCCBBCBCCCCCBCCBBCCBBBBCBCBCBBBCCCBCBCCBBCCBCBCBBCBCCBCBCCBCBBBCCCBCBCCBBCBCBBBCCCBBB...
result:
wrong answer your plan fails on CCCCBBBBBBB
Subtask #9:
score: 0
Wrong Answer
Test #9:
score: 0
Wrong Answer
time: 3ms
memory: 21860kb
input:
12
output:
CBBCBBBCBCCBCBCCBCCBCBBBBBBBCBBCBCCBCBCCCCBBBBBBCBBCBBBCCCCBCBCCBBCBCBBCCBCCCCBBCBBCCCBBBBCBCCBBCCBCCCBBBCCBCBBBCBCBCBCBCBBBCBBCBCCBCCCBCCBBBBBBCBBBCBCBCBCBCBCCCBCCBCCBBCCCCBCCCCBBBBCCCBCBCCBBCBBCBBBCBCCBCBCCBCCBCCBBCBBBCBBCCBCBCBCCCBCCCBCBCBBCBBBCBCCBCBBCBBCBCBCBCBCCCBCBCBCCBCBBCBCBCBCBCBBCCCBCCBCC...
result:
wrong answer your plan fails on CCCCBBBBBBBB
Subtask #10:
score: 0
Wrong Answer
Test #10:
score: 0
Wrong Answer
time: 0ms
memory: 22236kb
input:
13
output:
CCBBCBCCBBCBCCBBCBBCCCBBCCBBBCCCBBCBBCBBCCBBCBCBCBCBBBCCCCCBCCBBCCBCCCBBCBCCBCBCCBCBBBBCCBBBBCBBCCBBCBCBBCCCCBCBBCBCBCBBCCBBBCCCBCBBBCBBCCBBCCCBCBCBBBCCCBCBCCBBCCBBCCCBBBBCBBCBCBCBCCBBCCBCCCCBCBCBBCCCCBCBBCBBBBBCBCBBCCBBCBCCCCCBCCBBBCBBBCCBCBCBBBCCCCCBCCBBCCBCCCBBCBCCBCBCCBCBBBBCCBBBBCBBCBCBBBCCCCCB...
result:
wrong answer your plan fails on CCCCBBBBBBBBB
Subtask #11:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 0ms
memory: 24008kb
input:
14
output:
CBBCBBBCBCCBCBBCBCCBCBBBBBBBCBBCBCCBCCBCCBBBBBBBCBBCBBBCBCCBCBCCBCCBCBCCCCBBBBBBCBCBBBBBBCCBCBBBCBBBBCBBBCCBBBBBCBCBCBCBBBBBCBBCBCCBCCBCCBBBBBBBCBBBCCBBCCCBCBCCCBCCCBCCCBCCCBBBBCBBCBBBCBBBBBBBCBBCBBBCBCCBCBCCBCCBCBBBBBBBCBBCCCCBCBCCCCBBBBBBCBBCBBBCCCCBCBCCBCCBCBCBCCBBBBBBCBCBBBBBCBCBCBBCCBCCBCCBBCCC...
result:
wrong answer your plan fails on CCCCBBBBBBBBBB
Subtask #12:
score: 0
Wrong Answer
Test #12:
score: 0
Wrong Answer
time: 8ms
memory: 29968kb
input:
15
output:
CCBBCBCCBBCBCCBBCBCCCCBBCCBBBBCCBBBBCCBBCCBBCBCBCBCBBBCCCCCBCCBBCBCCCCBBCBCCBBBCCBCBBBBCCBBBBCBBCCBBCBCBBBCCCBCBBCBCCCBBCCBBBCCCBCBBCCBBCCBCCCCBCBCBBBBCCBBBBCBBCCBCCBCBBCBCBBCBCBCBBCBBCCBBCBCBCBCBBBBCCCBBBCBBBBCCCCBBCCBBCBCCCCCBBCBBCCBBBCCBCBCBBBCCCCCBCCBBCCCCCCBBCBCCBBBCCBCBBBBCCBBBBCBBCBCBBCCCCBBB...
result:
wrong answer your plan fails on CCCCBBBBBBBBBBB
Subtask #13:
score: 0
Wrong Answer
Test #13:
score: 0
Wrong Answer
time: 12ms
memory: 33128kb
input:
16
output:
CBBCBBBCBCCBCBBCBCCBBBBBBBBBCBBCBCCBCBBCCBBBBBBBCBBCBBBCBCCBCBBCBCCBCCBBCBBBBBBBCCBBBBBBBCCBCBBBCBBBBCBBBCCBBBBBCBCBCBCBBBBBCBBCBCCBCBBCCBBBBBBBCBCCCBBBBCCBCCBBCBCCCCBBCCBBCBBBBBCBCBBBCBBBBBBBCBBCBBBCBCCBCBBCBCCBCBBBBBBBCBBCBCCBCCBCCBBBBBBBCBBCBBBCBCCBCBCCBCCBCCBBCBBBBBBBCBBBCBBBCCCBCBCCCBCCCBCCCBCC...
result:
wrong answer your plan fails on CCCCBBBBBBBBBBBB
Subtask #14:
score: 0
Wrong Answer
Test #14:
score: 0
Wrong Answer
time: 44ms
memory: 49260kb
input:
17
output:
CCBBCBCCBBCBCCBBCBCCCCBBCCBBBBCCBBCBCCBBCCBBCBCBCBCBBBCCCCCBCCBBCBCCCCBBCBCBBBCCBBCBBBBCCBBBBCBBCCBBCBCBBBCCCBCBBBCCCCBBCCBBBBCCBBCBCCBBCCBCCBBBCBCBBBBCCBBBBCBBCCBCCCBBBBBCBBCBCBBBCCBBCCBBCBCBCBCBBBBCCBBBBCBBBBCCCCBBCCBBCBCCCCCBCCBBCCBBBCCBCBCBBBCCCCCBCCBBCCCCCCBBBBCBBBCCBBCBBBBCCBBBBCBBCBCCBCBCCCBB...
result:
wrong answer your plan fails on CCCCBBBBBBBBBBBBB
Subtask #15:
score: 0
Wrong Answer
Test #15:
score: 0
Wrong Answer
time: 92ms
memory: 63124kb
input:
18
output:
CBBCBBBCBCCBCBBCBCCBBBBBBBBBCBBCBCCBCBBCCBBBBBBBCBBCBBBCBCCBCBBCBCCBCBBBCBBBBBBBCBBBBBBBBCCBBBBBBBBBBCBBBCCBBBBBCBCBCBCBBBBBCBBCBCCBCBBCCBBBBBBBCBCBBBBBBCCBCBBBCCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBCBBBCBCCBCBBCBCCBBBBBBBBBCBBCBCCBCBBCCBBBBBBBCBBCBBBCBCCBCBBCBCCBCBBBCBBBBBBBCBBCCBBBBCCBCCBBCBCCCCBBCCBB...
result:
wrong answer your plan fails on CCCCBBBBBBBBBBBBBB