QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#120706#4327. Šeširiyoungsystem#94 199ms147216kbC++202.3kb2023-07-07 10:16:242024-05-26 01:47:55

Judging History

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

  • [2024-05-26 01:47:55]
  • 评测
  • 测评结果:94
  • 用时:199ms
  • 内存:147216kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-07 10:16:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int n=0,f=1,ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		n=n*10+ch-'0';
		ch=getchar();
	}
	return n*f;
}
vector<int>v[1000005];
int bu[2000005],bv[2000005],fx[2000005],vis[2000005],cnt;
bool visd[2000005];
int sta[1000005],ttop;
int now[1000005];
void dfs(int x)
{
	visd[x]=true;
	for(int i=now[x];i<v[x].size();i=now[x])
	{
		if(vis[v[x][i]])
		{
			now[x]=i+1;
			continue;
		}
		vis[v[x][i]]=true;
		now[x]=i+1;
		if(x==bu[v[x][i]])fx[v[x][i]]=0;
		else fx[v[x][i]]=1;
		int sth=bu[v[x][i]]+bv[v[x][i]]-x;
		dfs(sth);
	}
	sta[++ttop]=x;
}
int qans[20][500005];
int main()
{
	int n;
	n=read();
	for(int i=0;i<(1<<n);i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(i&(1<<(j-1)))continue;
			cnt++;
			bu[cnt]=2*i;
			bv[cnt]=2*(i^(1<<(j-1)))+1;
			v[bu[cnt]].push_back(cnt);
			v[bv[cnt]].push_back(cnt);
		}
	}
	for(int i=0;i<2*(1<<n);i++)
	{
		int sth=(int)v[i].size();
		if(sth%2==1)
		{
			cnt++;
			bu[cnt]=i;
			bv[cnt]=2*(1<<n);
			v[bu[cnt]].push_back(cnt);
			v[bv[cnt]].push_back(cnt);
		}
	}
	for(int i=0;i<=2*(1<<n);i++)
	{
		if(!visd[i])dfs(i);
	}
	for(int i=1;i<=cnt;i++)
	{
		if(bv[i]==2*(1<<n))continue;
		int bh=-1;
		for(int j=1;j<=n;j++)
		{
			if((bu[i]^bv[i])&(1<<j))
			{
				bh=j;
				break;
			}
		}
		int sy=0;
		for(int j=1;j<=n;j++)
		{
			if(j==bh)continue;
			int now=0;
			if((bu[i])&(1<<j))now=1;
			sy=sy*2+now;
		}
		if(fx[i]==0)qans[bh][sy]=0;
		else qans[bh][sy]=1;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<(1<<(n-1));j++)
		{
			if(qans[i][j])printf("C");
			else printf("B");
		}
		printf("\n");
	}
	return 0;
	for(int i=0;i<(1<<n);i++)
	{
		int z0=0,z1=0;
		for(int j=1;j<=n;j++)
		{
			if(i&(1<<(j-1)))z1++;
			else z0++;
		}
		int d0=0,d1=0;
		for(int j=1;j<=n;j++)
		{
			int sth=0;
			for(int k=1;k<=n;k++)
			{
				if(k==j)continue;
				if(i&(1<<(k-1)))sth=sth*2+1;
				else sth=sth*2;
			}
			int ans=0;
			if(i&(1<<(j-1)))ans=1;
			if(qans[j][sth]==0&&ans==0)d0++;
			if(qans[j][sth]==1&&ans==1)d1++;
		}
		if(d0<z0/2||d1<z1/2)
		{
			printf("wa %d %d %d %d %d\n",i,d0,z0,d1,z1);
			return 0;
		}
	}
	printf("ac\n");
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 7
Accepted

Test #1:

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

input:

4

output:

BCBCCBCC
CBCBBCBB
BCBCCBCC
CBCBBCBB

result:

ok good plan!

Subtask #2:

score: 7
Accepted

Test #2:

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

input:

5

output:

BBCBBBBCCBBBBBCB
BCBCCBCBBCBCCCBC
CBCBBCBCCBCBBBCB
BCBCCBCCBCBBCCBC
CBCBBCBBCBCCBBCB

result:

ok good plan!

Subtask #3:

score: 7
Accepted

Test #3:

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

input:

6

output:

BCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCC
CBCBBCBBCCBCBCCBBCBBCBBCBBCBBCBB
BCBCCBCCBCBBCBBCCBCCBCCBCCBCCBCC
CBCBBCBBCCBCBBCBBCBBCCBCBBCBBCBB
BCBCCBCCBBCCCCBCCBCCBCCBCCBCCBCC
CBCBBCBBCCBBBBCBBCBBCBBCBBCBBCBB

result:

ok good plan!

Subtask #4:

score: 7
Accepted

Test #4:

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

input:

7

output:

BBCBBBBCCBBBBBCBBBBCBCBBBBBBBBBCCBBBBBCBBCCBCBBBBBCBBBBCCBBBBBCB
BCBCCBCBBBBCCCBCCBCBBBCBCCCCCBCBBCBCCCBCBBBBBBBCCCBCCCCBBCBCCCBC
CBCBBCBBCCCCBCBBBCBCCCBCBBBBBCBCCBCBBBCBCCCCCCCBBBCBBBBCCBCBBBCB
BCBCCBCCBCBBCBCCCCCBBBCBCCBCCBCBBCBCCCBCBBCBBBBCCCBCCCCBBCBCCCBC
CBCBBCBBCCCCBCBBBBCCCCBCBBCBBCBCCBCBBCBB...

result:

ok good plan!

Subtask #5:

score: 7
Accepted

Test #5:

score: 7
Accepted
time: 2ms
memory: 24324kb

input:

8

output:

BCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCCBBCBBBBBCBCCBBCBCBBCBBCBBBCBCBBCCBCCBCCBCCBCCBCCBCCBCBBCCBBCBCCBCCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCC
CBCBBCBBCCBCBCCBBBBBCBBCBBCBBCBBCBBCCCCCBCBBCCBCBCCBCCBCCCBCBCCBBCBBCBBCBBCBBCBBCBBCBBCBBBCBCBBCBBCBBCBBCCBCBCCBBCBBCBBCBBCBBCBB
BCBCCBCCBBBBCBBCCBCCBCCBCCBCCBCCBCBBCBBCBB...

result:

ok good plan!

Subtask #6:

score: 7
Accepted

Test #6:

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

input:

9

output:

BBCBBBBCCBBBBBCBBBBCBCBBBCCBCBBCCBBBBBCBBBBBBBBBBBCBCBBCBBBBBCBBBBBCBCBBBBBBBBBBBCBBBBBBCBBBBBBBBBBBBBBBBBBBBBBBBBBCBBBBBBBBBBBCCBBBBBCBBCCBCBBCBBCBCBBCBBBCBCCBBCCBCBBCCBBCBCCBCBBBBCCBBCCBCBBBBBCBBBBCCBBBBBCBBBBCBCBBBBBBBBBCCBBBBBCBBCCBCBBBBBCBBBBCCBBBBBCB
BCBCCBCBBBCCCCBCCBCBBBCBCBBCBBCBBBCCBCBBBCC...

result:

ok good plan!

Subtask #7:

score: 7
Accepted

Test #7:

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

input:

10

output:

BCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCCBBCBBBBBCBCCBBCBCBBCBCCBBBCBCBBCCBCCBCCBCCBCCBCCBCCBCCCCCBCCBCCBCCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCCBBCBBBBBCBCCBBCBBBBBBBCBBBCBBBBBCBCCBBCBCBCCCCCCBBCBBBBBCBCCBBCBCBBCBBCBBBCBCBBCBBCBBBBBCBBCBBCBBBCBBBBBCBBCBCCBCBBCBBCBBBCBCBBCCBCCBCCBCCBCCBCCBCCBCBBCCBBCBCCBCCBCCBCCBBCB...

result:

ok good plan!

Subtask #8:

score: 7
Accepted

Test #8:

score: 7
Accepted
time: 4ms
memory: 31348kb

input:

11

output:

BBCBBBBCCBBBBBCBBBBCBCBBBCCBCBBCCBBBBBCBBBBBBBBBBBCBCBBBBBBCBBCBBBBCBCBBBCCBCBBCBCBBBBBCCBBBBCBBBCCBCBBBCBBBBBBBCBBBBBBBBBBBBBBCCBBBBBCBBBBBBBBBBBCBCBBBBBBCBBCBBBBBBBBCBBBCBCCBBBBCBCCBBCCBCBBBBBCBCBBCBBBBBCBBCBBCBBCBBCCBCBBCBBBBBCBBBBBBBBBBBCBBCBBCBBBBBCBBBBBCBCBBBBBBBBBBBCBBBBBCCBBBBCBBBBBBBBBBBBBB...

result:

ok good plan!

Subtask #9:

score: 7
Accepted

Test #9:

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

input:

12

output:

BCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCCBBCBBBBBCBCCBBCBCBBCBCCBBBCBCBBCCBCCBCCBCCBCCBCCBCCBCCCCCBCCBCCBCCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCCBBCBBBBBCBCCBBCBBBBBBCCBBBCBBBBBCBCCBBCBCBCCCCCCBBCBBBBBCBCCBBCBCBBCBBCBBBCBCBBCBBCBCBBCCBBCBCCBBBCBBBBBCBBCBCCBCBBCBCCBBBCBCBBCCBCCBCCBCCBCCBCCBCCBCCCCCBCCBCCBCCBCCBCCBBCB...

result:

ok good plan!

Subtask #10:

score: 7
Accepted

Test #10:

score: 7
Accepted
time: 8ms
memory: 42940kb

input:

13

output:

BBCBBBBCCBBBBBCBBBBCBCBBBCCBCBBCCBBBBBCBBBBBBBBBBBCBCBBBBBBCBBCBBBBCBCBBBCCBCBBCBCBBBBBCCBBBBCBBBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCCBBBBBCBBBBBBBBBBBCBCBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBCBBBBBBCBBCBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBBCBBBBCCBBBBCBBBBBCBCBBBCCBCBBCBCBBBBBCCBBBBCBBBCCBCBBBCBBB...

result:

ok good plan!

Subtask #11:

score: 6
Accepted

Test #11:

score: 6
Accepted
time: 8ms
memory: 52696kb

input:

14

output:

BCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCCBBCBBBBBCBCCBBCBCBBCBCCBBBCBCBBCCBCCBCCBCCBCCBCCBCCBCCCCCBCCBCCBCCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCCBBCBBBBBCBCCBBCBBBBBBCCBBBCBBBBBCBCCBBCBCBCCCCCCBBCBBBBBCBCCBBCBCBBCBBCBBBCBCBBCBBCBCBBCCBBCBCCBBBCBBBBBCBBCBCCBCBBCBCCBBBCBCBBCCBCCBCCBCCBCCBCCBCCBCCCCCBCCBCCBCCBCCBCCBBCB...

result:

ok good plan!

Subtask #12:

score: 6
Accepted

Test #12:

score: 6
Accepted
time: 32ms
memory: 64924kb

input:

15

output:

BBCBBBBCCBBBBBCBBBBCBCBBBCCBCBBCCBBBBBCBBBBBBBBBBBCBCBBBBBBCBBCBBBBCBCBBBCCBCBBCBCBBBBBCCBBBBCBBBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCCBBBBBCBBBBBBBBBBBCBCBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBCBBBBBBCBBCBCBBCBCCBBCCBCBBBBBBBBBBBBBBBBBBCBBCBBBBBCBBCBBCBBBBCBCBBBCCBCBBCBCBBBBBCCBBBBCBBBCCBCBBCCBBC...

result:

ok good plan!

Subtask #13:

score: 6
Accepted

Test #13:

score: 6
Accepted
time: 89ms
memory: 111640kb

input:

16

output:

BCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCCBBCBBBBBCBCCBBCBCBBCBCCBBBCBCBBCCBCCBCCBCCBCCBCCBCCBCCCCCBCCBCCBCCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCCBBCBBBBBCBCCBBCBBBBBBCCBBBCBBBBBCBCCBBCBCBCCCCCCBBCBBBBBCBCCBBCBCBBCBBCBBBCBCBBCBBCBCBBCCBBCBCCBBBCBBBBBCBBCBCCBCBBCBCCBBBCBCBBCCBCCBCCBCCBCCBCCBCCBCCCCCBCCBCCBCCBCCBCCBBCB...

result:

ok good plan!

Subtask #14:

score: 6
Accepted

Test #14:

score: 6
Accepted
time: 199ms
memory: 147216kb

input:

17

output:

BBCBBBBCCBBBBBCBBBBCBCBBBCCBCBBCCBBBBBCBBBBBBBBBBBCBCBBBBBBCBBCBBBBCBCBBBCCBCBBCBCBBBBBCCBBBBCBBBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCCBBBBBCBBBBBBBBBBBCBCBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBCBBBBBBCBBCBCBBCBCCBBCCBCBBBBBBBBBBBBBBBBBBCBBCBBBBBCBBCBBCBBBBCBCBBBCCBCBBCBCBBBBBCCBBBBCBBBCCBCBBCCBBC...

result:

ok good plan!

Subtask #15:

score: 0
Runtime Error

Test #15:

score: 0
Runtime Error

input:

18

output:


result: