QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#412021#8369. T2zhouhuanyi65 197ms20692kbC++141.3kb2024-05-15 23:10:242024-05-15 23:10:24

Judging History

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

  • [2024-05-15 23:10:24]
  • 评测
  • 测评结果:65
  • 用时:197ms
  • 内存:20692kb
  • [2024-05-15 23:10:24]
  • 提交

answer

#include<iostream>
#include<cstdio>
#define N 22
using namespace std;
int read()
{
	char c=0;
	int sum=0;
	while (c<'0'||c>'9') c=getchar();
	while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
	return sum;
}
int n,cl[1<<N],a[1<<N],length,nt[1<<N],leng,st[N+1];
bool used[1<<N];
void solve(int x,int d)
{
	if (d==n)
	{
		a[x]=++length;
		return;
	}
	solve(x<<1,d+1);
	int ps=length;
	for (int i=2;i<=ps;++i)
		if (i!=a[x<<1])
			nt[i]=++length;
	nt[a[x<<1]]=a[x<<1],a[x]=++length;
	for (int i=d+1;i<=n;++i)
		for (int j=(x<<(i-d));j<(x<<(i-d))+(1<<(i-d-1));++j)
			a[(x<<(i-d+1))+(1<<(i-d))-1-j]=nt[a[j]];
	if (d) a[(x<<(n-d))|((1<<(n-d))-1)]=a[x];
	else a[(x<<(n-d))|((1<<(n-d))-1)]=++length;
	if (n-d>=3&&d)
	{
		int ds=x;
		leng=0;
		while (ds<=(1<<(n+1))-1) st[++leng]=a[ds],ds=(ds<<1)|1;
		for (int i=1;i<=leng-i+1;++i)
			if (st[i]!=st[leng-i+1])
			{
				for (int j=1;j<=(1<<(n+1))-1;++j)
					if (a[j]==st[leng-i+1])
						a[j]=st[i];
			}
	}
	return;
}
int main()
{
	n=read();
	if (n==1)
	{
		puts("1");
		puts("1 1 1");
		return 0;
	}
	solve(1,0);
	for (int i=1;i<=(1<<(n+1))-1;++i) used[a[i]]=1;
	leng=0;
	for (int i=1;i<=length;++i)
		if (used[i])
			cl[i]=++leng;
    printf("%d\n",leng);
	for (int i=1;i<=(1<<(n+1))-1;++i) printf("%d ",cl[a[i]]);
	puts("");
	return 0;
}

詳細信息

Subtask #1:

score: 11
Accepted

Test #1:

score: 11
Accepted
time: 0ms
memory: 3648kb

input:

1 12

output:

1
1 1 1

result:

ok OK

Test #2:

score: 0
Accepted
time: 1ms
memory: 7904kb

input:

2 12

output:

4
3 2 2 1 2 2 4 

result:

ok OK

Test #3:

score: 0
Accepted
time: 1ms
memory: 7956kb

input:

3 12

output:

6
5 3 3 2 2 4 4 1 2 2 3 3 4 4 6 

result:

ok OK

Test #4:

score: 0
Accepted
time: 1ms
memory: 7888kb

input:

4 12

output:

8
7 4 4 3 3 6 6 2 2 3 3 6 6 5 5 1 2 2 3 3 3 3 4 4 6 6 6 6 5 5 8 

result:

ok OK

Subtask #2:

score: 8
Accepted

Test #5:

score: 8
Accepted
time: 90ms
memory: 12428kb

input:

19 1100000

output:

87402
87401 43701 43701 21855 21855 65555 65555 10932 10932 32778 32778 76478 76478 54632 54632 5470 5470 16393 16393 38239 38239 27316 27316 71016 71016 81939 81939 60093 60093 49170 49170 2739 2739 8201 8201 19124 19124 13662 13662 35508 35508 40970 40970 30047 30047 24585 24585 68285 68285 73747 ...

result:

ok OK

Test #6:

score: 0
Accepted
time: 189ms
memory: 18832kb

input:

20 1100000

output:

174784
174783 87392 87392 43701 43701 131092 131092 21855 21855 65546 65546 152937 152937 109246 109246 10932 10932 32778 32778 76469 76469 54623 54623 142014 142014 163860 163860 120169 120169 98323 98323 5470 5470 16393 16393 38239 38239 27316 27316 71007 71007 81930 81930 60084 60084 49161 49161 ...

result:

ok OK

Subtask #3:

score: 15
Accepted

Test #7:

score: 15
Accepted
time: 91ms
memory: 14296kb

input:

19 600000

output:

87402
87401 43701 43701 21855 21855 65555 65555 10932 10932 32778 32778 76478 76478 54632 54632 5470 5470 16393 16393 38239 38239 27316 27316 71016 71016 81939 81939 60093 60093 49170 49170 2739 2739 8201 8201 19124 19124 13662 13662 35508 35508 40970 40970 30047 30047 24585 24585 68285 68285 73747 ...

result:

ok OK

Test #8:

score: 0
Accepted
time: 197ms
memory: 20692kb

input:

20 600000

output:

174784
174783 87392 87392 43701 43701 131092 131092 21855 21855 65546 65546 152937 152937 109246 109246 10932 10932 32778 32778 76469 76469 54623 54623 142014 142014 163860 163860 120169 120169 98323 98323 5470 5470 16393 16393 38239 38239 27316 27316 71007 71007 81930 81930 60084 60084 49161 49161 ...

result:

ok OK

Subtask #4:

score: 16
Accepted

Test #9:

score: 16
Accepted
time: 190ms
memory: 18720kb

input:

20 5000

output:

174784
174783 87392 87392 43701 43701 131092 131092 21855 21855 65546 65546 152937 152937 109246 109246 10932 10932 32778 32778 76469 76469 54623 54623 142014 142014 163860 163860 120169 120169 98323 98323 5470 5470 16393 16393 38239 38239 27316 27316 71007 71007 81930 81930 60084 60084 49161 49161 ...

result:

ok OK

Test #10:

score: 0
Accepted
time: 87ms
memory: 12424kb

input:

19 5000

output:

87402
87401 43701 43701 21855 21855 65555 65555 10932 10932 32778 32778 76478 76478 54632 54632 5470 5470 16393 16393 38239 38239 27316 27316 71016 71016 81939 81939 60093 60093 49170 49170 2739 2739 8201 8201 19124 19124 13662 13662 35508 35508 40970 40970 30047 30047 24585 24585 68285 68285 73747 ...

result:

ok OK

Subtask #5:

score: 15
Accepted

Test #11:

score: 15
Accepted
time: 86ms
memory: 14372kb

input:

19 200

output:

87402
87401 43701 43701 21855 21855 65555 65555 10932 10932 32778 32778 76478 76478 54632 54632 5470 5470 16393 16393 38239 38239 27316 27316 71016 71016 81939 81939 60093 60093 49170 49170 2739 2739 8201 8201 19124 19124 13662 13662 35508 35508 40970 40970 30047 30047 24585 24585 68285 68285 73747 ...

result:

ok OK

Test #12:

score: 0
Accepted
time: 189ms
memory: 18640kb

input:

20 200

output:

174784
174783 87392 87392 43701 43701 131092 131092 21855 21855 65546 65546 152937 152937 109246 109246 10932 10932 32778 32778 76469 76469 54623 54623 142014 142014 163860 163860 120169 120169 98323 98323 5470 5470 16393 16393 38239 38239 27316 27316 71007 71007 81930 81930 60084 60084 49161 49161 ...

result:

ok OK

Subtask #6:

score: 0
Wrong Answer

Test #13:

score: 0
Wrong Answer
time: 91ms
memory: 18308kb

input:

19 12

output:

87402
87401 43701 43701 21855 21855 65555 65555 10932 10932 32778 32778 76478 76478 54632 54632 5470 5470 16393 16393 38239 38239 27316 27316 71016 71016 81939 81939 60093 60093 49170 49170 2739 2739 8201 8201 19124 19124 13662 13662 35508 35508 40970 40970 30047 30047 24585 24585 68285 68285 73747 ...

result:

FAIL Condition failed: "1<=sum[i]&&sum[i]<=K"