QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#120891#4327. Šeširiabs998244353#7 214ms76772kbC++171.3kb2023-07-07 12:18:042024-07-04 00:28:07

Judging History

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

  • [2024-07-04 00:28:07]
  • 评测
  • 测评结果:7
  • 用时:214ms
  • 内存:76772kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-07 12:18:04]
  • 提交

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[u]^=1;deg[v]^=1;
	nxt[++tot]=hd[u];hd[u]=tot;ver[tot]=v;
}
void dfs(int u){
	deg[u]^=1;
	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;
	}
}
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]&1) que[++tl]=i;
	}
	for(int pos=1;pos<=tl;++pos){
		int u=que[pos];
		if(deg[u]){
			dfs(u);
			int par=(u>=(1<<n));
			while(tp){
				res[stk[tp--]]=par;
				par^=1;
			}
		}
	}
	for(int i=0;i<(1<<(n+1));++i){
		dfs(i);
		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: 17696kb

input:

4

output:

BBCCCBBC
CCBBCCCB
BBCCBBCC
CBBBCCBB

result:

wrong answer your plan fails on CCCB

Subtask #2:

score: 7
Accepted

Test #2:

score: 7
Accepted
time: 0ms
memory: 17716kb

input:

5

output:

BBCBBBBBCBCCCBCC
CCBCCCCCBCBBBCBB
BBCCBBBBCCCCBBCC
CCBBCCBCBBCBBCBB
BBCBBBCBCCCCCBCB

result:

ok good plan!

Subtask #3:

score: 0
Wrong Answer

Test #3:

score: 0
Wrong Answer
time: 0ms
memory: 19716kb

input:

6

output:

BBCCCCCCCCBBBCCCCBBBBBBBBBBBCBCC
CCBBCCBBBBCCCBBBCCCCCCBCCCBBCCBB
BBCCBBBCCCBBBBCCBBCCCCCBCCCCBBCC
CBBBCCCBBBBBBBCBCCCCCCBCBBBBCCCB
BBCCBBBCCCCCCCBCBBBBBBCBBBCCCBCC
CBBBCCBBBBBBBBCBCCCCCCBCCCBBBCBB

result:

wrong answer your plan fails on CCCBBB

Subtask #4:

score: 0
Wrong Answer

Test #4:

score: 0
Wrong Answer
time: 0ms
memory: 19752kb

input:

7

output:

BBCCBCBBCBCCBBCCBCBBBBCCCBCBCBCBCBCCCBCCCBCBBCBCBCBCCBCBBBBCCBCC
CCBBCBCCBCBBBCBBCBCCCCBBBCBCBCBCBCBBBCBBBCBCCBCBCBCBBCCCCCCBBCBB
BBCBBBCBCBCCCBCCBBCBBBCCCBCBBCCBCBCCCBCCCBCCCBBCBCBBCBCBBCBCCBCC
CCBCCCBCBBCBBCBBCCBCCBCBBBCBCBCCBBCBBCBCBCBCBCCBCBCCBBBCCBCBBCBB
BBCBBBCBCCBCCBCBBBBBBBBBCBBBBCBBCCCCCCCB...

result:

wrong answer your plan fails on CCCCBBB

Subtask #5:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 0ms
memory: 19752kb

input:

8

output:

BBCCCBBBCBCBCCBCCCCBCBBCCCBCCCBCCCBBBCCCCBBBCCCBCBCBCCCBCBCCBCBCCBBBBBBBCCBBBCCBCBCCCBCBBBBCBBCBCBCBCCCCCCCCCCCBBBBCCCBBBBBBBBCC
CCBBCCCCBBBCBBBBCCBCBCCCBBCCCBCBBBCCCBBBBCBCCCBCBCBCCCBCBBBBCCBBCCCCCCBCBBCCBCBCBCBCCCBCCCCBCCCCBCBBCCBBCCBBBBCBBCCBBBBCCCCBBCBB
BBCCBBCBCCCCCCCCBBBBBCBBBCBBBCBCCCBBBBCCCC...

result:

wrong answer your plan fails on CCCCBBBB

Subtask #6:

score: 0
Wrong Answer

Test #6:

score: 0
Wrong Answer
time: 0ms
memory: 19776kb

input:

9

output:

BBCBBBBBCBCCCBCCBCBBBBCBBBCBCCBBCBCCCBCBBBCCBBCCCCBBCCCBBBCCCBCBBCBBBBCCCCBBCBCBCCBBCCCBBBCCCBCBCBCBBBCCCCCBBCBBCBBBCBCBBBCCCCBBCBCCCBCCBBCBBBBCCCBBCCCBBCCCBBCCBBCBBBCCCCCBBCBCBBBCCBCCBBCCBCCCBCBCCBBBBCBCCBCCCBCBBBCBCBCBBCBBBCBCBBCBCBCCCBCCCCBBCCBBBCBCBBCC
CCBCCCCCBCBBBCBBCBCCCCBCCCBCBBCCBCBBBCBCCCB...

result:

wrong answer your plan fails on CCCCBBBBB

Subtask #7:

score: 0
Wrong Answer

Test #7:

score: 0
Wrong Answer
time: 2ms
memory: 23848kb

input:

10

output:

BBCCCCCCCCBBBCCCCBBBBBBBBBBBCBCBCBCCCCBCBBBCCCBBCBCBCBCBCBBBBCBCCCCCCBCCBBBBCBCBCCBCCCCBBCBBCBBCCCBBBCBCBCCBCBBCBBCBCBCCBBCCCCBCCCBCBCCBBBBBCBCBCBCBCCCBCBCCBCBCBBCBCCCBCBCBCCBBCCBBCBBCBCBCCCBBBCBBBCCCBBCBCCCBBCBBCBBCBBBCCCBCCCCCCCBBCBBBCBCCCBCBCCCCBCBBBCCCCBBBBBBBBCBBBCCBBBCCCBCBBBBCBBCBBBCBCCCCCCCC...

result:

wrong answer your plan fails on CCCBBBBBBB

Subtask #8:

score: 0
Wrong Answer

Test #8:

score: 0
Wrong Answer
time: 0ms
memory: 19784kb

input:

11

output:

BBCCBCBBCBCCBBCBBCBBBBCBCBCCCCBBCBCCCBCBCBCCBBCCBCBBCCBBBCCCBBCBBCBBBBCCBCBCCCBBBCBCCBBBBBCCCBCBCBCBBBCCCCCBBCBCCBBBBBCCCBCCCBCBCBCCCBCCCBCBBBCCCCBCCBBBBBCCCBCCBBCBBBCCCBBBCCBCBCBCBBCCBBCBBCBCCCBCCBBBBCCCCBCCCCBBCBCBBBCCBBCBBBCCBBCBCBCBCCBCCCBBCBBBBCCCBBCCBCBBBBCBBCBBCBCBBCBBCCCBBBCCCBCBCCBBCBCBBCCC...

result:

wrong answer your plan fails on CCCCBBBBBBB

Subtask #9:

score: 0
Wrong Answer

Test #9:

score: 0
Wrong Answer
time: 0ms
memory: 24000kb

input:

12

output:

BBCCCBBCCBCCCBCCCCCCCCCCCBCCBCBCCCBCBBBBCCCCBCBBCCBCBCCBBBBCCCBCCBBCBCCBCBCBCBCBCCBBBBCBCCBCBBCCCCBCBBCCBBBCBCCCCBCCBCBCBBBCBCBCCBCBCCBCCCCBBCBCCBCBBCBCCCBCBBCBBBCBCCCBCCCCCBCCBBBCCCBCBCCCBCBCBCBBCCCCCBCBCBBBBBCCCCCBCCCBBBCCBCCBCBCBBCCBBBCCBCBBBBCCBBBBBCBCCCCBCBCCCCCBBBCCBCBBBCBCBBCCCCCBBBCCCBBBCBBC...

result:

wrong answer your plan fails on CCCBBBBBBBBB

Subtask #10:

score: 0
Wrong Answer

Test #10:

score: 0
Wrong Answer
time: 3ms
memory: 22220kb

input:

13

output:

BBCBBBBBCBCCCBCBBCBBBBCCBBCCCBCBCBCCCBCCBBCBBCBCCCBCCBBBBCBCBBCBBCBBBBCBCCBCCCBBCCBCCBBBBCBCBBCCCBCCBCBCCBBBCCBBCCCBBBCBCBCCCCCBCBCCCBCBBBCCBCCCCCBCCBBBBBBCCBCCBBCCBCBCCBBBCCBCBCCCBBCBCBCCBCBCBCBBCCCBBBCCBBCCCCBBCBCBBBCBBCBBBBCCCBCBBBCCCBCCBCBBCCBBBCBCBBCCBCBBBBCCBCBBCCCBBCBCCBBBBBCCCBCBCCBCCBBBBBBC...

result:

wrong answer your plan fails on CCCBBBBBBBBBB

Subtask #11:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 3ms
memory: 24572kb

input:

14

output:

BBCCCCCCCCBBBCCCCBBBBBBBBBBBCBCCCBCCCCBCBBBBCBCCCBCBCBBCCCCCBBCCCCCCCBCCBBBCCCBCCCBCCCBCBBCCCCCBCCBBBCBBBCCCCCCBBCBCCCBBCCBBBBCBCCBCBCCBBBBCCCBCCBCCCBCCCCBBBBCBBBCBCCCCCCCCCBCCCBBCCCCBBBCBBBCCBCBCBBCBBBBCBBBCBBCCBCCBBCCBBBCBCCCBCBCCBCCCBCBBCCBCBBBBCBCCCBBCCBBBBBBBBCBCBBCCBBCCCBCCBBCBCCBCBBCCCBBBCBBB...

result:

wrong answer your plan fails on CCCBBBBBBBBBBB

Subtask #12:

score: 0
Wrong Answer

Test #12:

score: 0
Wrong Answer
time: 11ms
memory: 29752kb

input:

15

output:

BBCCBCBBCBCCBBCBBCBBBBCBCBCCCCBBCBCCCBCBCBCCBBCCBCBBCCBBBCCCBBCCBCBBBBCCBCBCCCBBBCBCCBBBBBCCCBCCCBCBBBCCCCCBBCBBCBBBBBCBCBCBCCBBCBCCCBCCCBCBBBCCCCBCCBBBBBCCCBCBBBCBBBCCCBBBCCBBBCBCBBCCBBCCBBCCCCBCCBBBBCCCCBCBCCBBCBCBBBCBBCBBBBCCBBCCCBCCCBCCCCBCCCCBBBBCCBCCBCBBBBCBBCBBCBCBBCBBCCCBBBCCCBCCCCBBCBCBBCCC...

result:

wrong answer your plan fails on CCCCBBBBBBBBBBB

Subtask #13:

score: 0
Wrong Answer

Test #13:

score: 0
Wrong Answer
time: 31ms
memory: 35416kb

input:

16

output:

BBCCCBBBCBCBCCBCCCCBCBBBCCBBCBCCCCBBBCCCCBBBCBCBCBCBCBBBCCCCBCBCCBBBBBBCCCBCBCBBCBCCCCBBBBCCCBCCCBCBCCBCCCCCCCCCBCBCCCBCCBBCBCBBCBCCCBCBCBBCCCBCCCBCCBCCBCBCBBCBBCBBBCCBBCCCCBCCCBBCCCBCBCCCBCBBBBCCBBCCBBBBBBBBCBCCBCCBBCCBBBCBCCCBCBCBBCCBBBCBCCBBBBCBBBBCBBCCCCCCCCBBCBBCCBCCBBCCCBCCCBCCCCCBBCBCBBBBBBBC...

result:

wrong answer your plan fails on CCCCBBBBBBBBBBBB

Subtask #14:

score: 0
Wrong Answer

Test #14:

score: 0
Wrong Answer
time: 80ms
memory: 47320kb

input:

17

output:

BBCBBBBBCBCCCBCCBCBBBBCBBBCBCCBBCBCCCBCBBBCCBBCCCCBBCCCBBBCCCBCBBCBBBBCCCCBBCBCBCCBBCCCBBBCCCBCCCBCBBBCCCCCBBCBBCBBBCBCBBBCCCCCBCBCCCBCCBBCBBBBCCCBBCCCBBCCCBBCCBBCBBBCCCCCBBCBCBBBCCBCBBBCCBCBCBCBCCBBBBCBCCBCCCBCBBBCBCBCBBCBBBCBCBBCBCBCCCBCCCCBBCCBBBCBCBBCBBCBBBBCBBCBCCBBBBCBBCCCBBCBCBBCCCCBBCCCBBCCC...

result:

wrong answer your plan fails on CCCCBBBBBBBBBBBBB

Subtask #15:

score: 0
Wrong Answer

Test #15:

score: 0
Wrong Answer
time: 214ms
memory: 76772kb

input:

18

output:

BBCCCCCCCCBBBCCCCBBBBBBBBBBBCBCBCBCCCCBCBBBBCBCBCBCBCBBBCCCBBCBCCCCCCBCCBBBCCCBBCCBCCCBBBBCBCBBCCCBBBCBCBCCBCBBCBCBBCBCCCBCCCCBCCCBCBCCBBBBCCCBBCBCCCBCBCCBCBCBCBBCBCCCBCCCBCCBBCBBBCBBCBCBCCCBBBCBCBBCCBBBBBCCBBBCBBBBCBBBCCCBCCCCCCCBBBBBBCBCCCBCBCCCCBCBBBCCCCBBBBBBBBCBCBBCBBBCCCBCBBBCCCBCBBBCCCBBCCBBC...

result:

wrong answer your plan fails on CCCBBBBBBBBBBBBBBB