QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#469696#6376. LaLa and Lampcppcppcpp3WA 0ms3844kbC++141.1kb2024-07-09 22:01:482024-07-09 22:01:48

Judging History

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

  • [2024-07-09 22:01:48]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3844kb
  • [2024-07-09 22:01:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=2005;

int n,a[N][N],c[N<<1];
char s[N];

int cnt,head[N<<1];
struct edge{
	int to,w,nxt;
}e[N<<3];
void add(int u,int v,int w){e[++cnt]={v,w,head[u]},head[u]=cnt;}

bool vs[N<<1];
bool dfs(int u){
	vs[u]=1;
	for(int i=head[u];i;i=e[i].nxt){
		int v=e[i].to,w=e[i].w;
		if(!vs[v]){
			c[v]=w^c[u];
			if(!dfs(v)) return 0;
		}else if(c[v]^w^c[u]) return 0;
	}
	return 1;
}

signed main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		scanf("%s",s);
		for(int j=0;j<=i;++j) a[i][j]=s[j]-48;
	}
	for(int p=0;p<2;++p){
		for(int q=0;q<2;++q){
			for(int o=0;o<2;++o){
				cnt=0;
				memset(head,0,sizeof head);
				memset(vs,0,sizeof vs);
				memset(c,0,sizeof c);
				for(int i=0;i<n-1;++i){
					int w=p^a[n-2][i],u=i,v=n+i+1;
					add(u,v,w),add(v,u,w);
				}
				for(int i=0;i<n;++i){
					int w=q^a[n-1][i],u=i,v=n+i;
					add(u,v,w),add(v,u,w);
				}
				c[0]=o;
				if(dfs(0)){
					// for(int i=0;i<2*n;++i) cout << c[i] << ' ';
					// puts("");
					puts("Yes"),exit(0);
				}
			}
		}
	}
	puts("No");
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3844kb

input:

6
0
00
000
0110
00100
000000

output:

Yes

result:

ok answer is YES

Test #2:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

2
0
11

output:

Yes

result:

ok answer is YES

Test #3:

score: 0
Accepted
time: 0ms
memory: 3836kb

input:

3
1
10
011

output:

Yes

result:

ok answer is YES

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3840kb

input:

4
1
11
101
0101

output:

Yes

result:

wrong answer expected NO, found YES