QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#691412#7900. Gifts from KnowledgeHomuraAkemi#WA 45ms43148kbC++141.5kb2024-10-31 11:22:562024-10-31 11:22:57

Judging History

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

  • [2024-10-31 11:22:57]
  • 评测
  • 测评结果:WA
  • 用时:45ms
  • 内存:43148kb
  • [2024-10-31 11:22:56]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define LL long long
struct edge{
	LL to,nt;
}a[10000005];
LL n,i,j,k,m,t,cnt=0,ans=0;
LL sum[1000005],col[1000005],deg[1000005],stat[1000005],nxt[1000005];
string s[1000005];
bool vis[1000005];
bool flag;
const LL mod=1e9+7;
void add(LL x,LL y){
	//printf("%lld %lld\n",x,y);
	deg[x]++;
	a[++cnt].to=y;a[cnt].nt=nxt[x];nxt[x]=cnt;
}
void dfs(LL x){
	vis[x]=true;
	for(LL i=nxt[x];i;i=a[i].nt){
	    if(vis[a[i].to]==false) stat[a[i].to]=stat[x]^1,dfs(a[i].to);
	    else if(stat[a[i].to]==stat[x]) flag=true;
	}
}
int main(){
	scanf("%lld",&t);
	while(t--){
		for(i=1;i<=n;i++)
		  nxt[i]=0,stat[i]=0,vis[i]=false,deg[i]=0;
		for(i=1;i<=m;i++)
		  sum[i]=0;
		scanf("%lld%lld",&n,&m);
		for(i=1;i<=n;i++){
			s[i]="";
			cin>>s[i];s[i]=" "+s[i];
		}
		for(i=1;i<=n;i++){
			for(j=1;j<=m;j++)
			  if(s[i][j]=='1') sum[j]++;
		}
		flag=false;
		for(i=1;i<=(m)/2;i++){
			if(sum[i]+sum[m-i+1]<=2){
		  		if(sum[i]+sum[m-i+1]==2){
		  			LL x=0,y=0;
		  			for(j=1;j<=n;j++)
		  		  	  if(s[j][i]=='1' || s[j][m-i+1]=='1'){
		  		  		if(x==0) x=j;
		  		  		else y=j;
				  	  }
				    if(y>0) add(x,y),add(y,x);
				}
		  	}
		  	else{
		  		flag=true;break;
			  }
		}
		if(m%2==1){
		    if(sum[(m+1)>>1]>1){
				flag=true;
			}
		}
		if(flag==true){
			printf("0\n");
			continue;
		}
		LL ans=1;
		for(i=1;i<=n;i++)
		  if(vis[i]==false) dfs(i),ans*=2,ans%=mod;
		if(flag==true){
			printf("0\n");
			continue;
		}
		printf("%lld\n",ans);
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 43148kb

input:

3
3 5
01100
10001
00010
2 1
1
1
2 3
001
001

output:

4
0
2

result:

ok 3 number(s): "4 0 2"

Test #2:

score: 0
Accepted
time: 45ms
memory: 42904kb

input:

15613
10 10
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
15 8
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
1 5
00000
5 9
000000000
000000000
0000...

output:

1024
32768
2
32
32768
128
32
16
16
2
16384
16384
128
128
32768
8192
128
64
16384
2
4
2
4096
16
4096
1024
32768
32768
16384
8
128
2
16
4096
8192
32768
8192
8192
16
16384
16384
256
128
8
256
8
4096
512
2
4
32
32
2
64
512
1024
32768
32768
2
64
16384
16
8192
16
256
16
64
8192
8192
64
1024
2
32768
2
4
51...

result:

ok 15613 numbers

Test #3:

score: -100
Wrong Answer
time: 30ms
memory: 41592kb

input:

15759
9 6
000000
000000
000000
000000
000000
000000
000000
000000
000000
5 15
010000000000000
000000000000000
000000000000000
000100000000000
000100000000000
14 12
000000000000
000000000000
000000000000
000000000000
000000000000
000000000000
000000000000
000000000000
000000000000
000000000000
000000...

output:

512
16
16384
512
1024
4096
32768
4
2
512
512
512
512
8
2
256
16
4096
512
64
16
4096
512
32
32768
8192
32
2048
128
16
4096
64
32768
256
32
16384
8
512
32
2048
8
16
1024
2048
128
64
32
8
512
8
8192
256
8192
32768
2
8
512
512
256
32
2
2048
8192
8
64
8
2
16384
32768
32768
1024
4096
16384
16384
128
256
4...

result:

wrong answer 2380th numbers differ - expected: '0', found: '4'