QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#469696 | #6376. LaLa and Lamp | cppcppcpp3 | WA | 0ms | 3844kb | C++14 | 1.1kb | 2024-07-09 22:01:48 | 2024-07-09 22:01:48 |
Judging History
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");
}
详细
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