QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#326861#7303. City UnitedForg1weNWA 1ms3884kbC++14917b2024-02-14 11:25:342024-02-14 11:25:35

Judging History

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

  • [2024-02-14 11:25:35]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3884kb
  • [2024-02-14 11:25:34]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn=1<<14;
int n,m,ans;
int f[maxn];
int G[55][55];
void pt() {
	for(int i=1;i<=(1<<12)-1;i++)
		ans=(ans+f[i]/2)%2;
	printf("%d",ans);
}
int main() {
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) {
		int u,v;
		scanf("%d%d",&u,&v);
		G[u][v]=G[v][u]=1;
	}
	for(int i=1;i<=min(n,12);i++) {
		int tot=(1<<i-1)-1;
		f[1<<(i-1)]=2;
		for(int j=1;j<=tot;j++) {
			bool pd=0;
			for(int k=1;k<i;k++) 
				if((j>>k-1&1)&&G[i][k])pd=1;
			if(pd==1)f[j+(1<<(i-1))]=f[j];
			else f[j+(1<<(i-1))]=f[j]*2%4;
		}
	}
	if(n<=12)pt();
	else {
		int tot=(1<<12)-1;
		for(int i=13;i<=n;i++) {
			for(int j=1;j<=tot;j++) {
				bool pd=0;
				for(int k=1;k<=12;k++) 
					if((j>>k-1&1)&&G[i][i-12+k])pd=1;
				if(pd==1)f[(1<<11)+(j>>1)]=f[j];
				else f[(1<<11)+(j>>1)]=f[j]*2%4;
			}
		}
		pt();
	}
	return 0;
}
/*
3 2
1 2
2 3
*/

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3864kb

input:

3 2
1 2
2 3

output:

0

result:

ok 1 number(s): "0"

Test #2:

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

input:

3 3
1 2
2 3
3 1

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3884kb

input:

15 31
9 5
14 5
2 7
5 15
11 14
11 9
2 6
3 4
12 1
6 8
3 5
11 10
15 6
4 1
1 2
8 9
6 12
14 10
13 2
4 5
3 8
3 15
11 6
7 5
4 6
11 2
13 15
3 2
8 4
6 13
7 10

output:

0

result:

wrong answer 1st numbers differ - expected: '1', found: '0'