QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#130045 | #6376. LaLa and Lamp | qwqwf | WA | 2ms | 7796kb | C++14 | 1.6kb | 2023-07-23 14:58:16 | 2023-07-23 14:58:19 |
Judging History
answer
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<set>
#include<queue>
#include<bits/stdc++.h>
#define ll long long
#define int ll
using namespace std;
const int N=2e3+10;
inline int read(){
int d=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){d=(d<<1)+(d<<3)+(ch^48);ch=getchar();}
return d*f;
}
int n,a[N][N],b[N][N];
char s[N][N];
bool check(){
for(int i=1;i<=n;i++) for(int j=1;j<=i;j++) b[i][j]=a[i][j];
if(b[n-1][1]) b[n-1][1]^=1,b[n][2]^=1;
for(int i=2;i<=n;i++){
if(b[n][i]) for(int j=n;j>=i;j--) b[j][i]^=1;
if(i!=n&&b[n-1][i]){
for(int j=n,p=i+1;p&&j;p--,j--) b[j][p]^=1;
}
}
bool fl;int x;
for(int i=1;i<=n;i++){
x=b[i][1];
for(int j=2;j<=n;j++) if(b[i][j]!=x) return false;
}return true;
}
signed main(){
n=read();
for(int i=1;i<=n;i++) scanf("%s",s+1);
for(int i=1;i<=n;i++) for(int j=1;j<=i;j++) a[i][j]=s[i][j]=='1';
for(int i=0;i<=1;i++){
if(i) for(int t=1;t<=n-1;t++) a[n-1][t]^=1;
for(int j=0;j<=1;j++){
if(j) for(int t=1;t<=n;t++) a[n][t]^=1;
for(int k=0;k<=1;k++){
if(k) a[n][1]^=1;
if(check()) return puts("Yes"),0;
if(k) a[n][1]^=1;
}
if(j) for(int t=1;t<=n;t++) a[n][t]^=1;
}
if(i) for(int i=1;i<=n-1;i++) a[n-1][i]^=1;
}
return puts("No"),0;
// for(int i=1;i<=n-1;i++) a[n-1][i]^=1;
// for(int i=1;i<=n;i++) a[n][i]^=1;
// a[n][1]^=1;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 7624kb
input:
6 0 00 000 0110 00100 000000
output:
Yes
result:
ok answer is YES
Test #2:
score: 0
Accepted
time: 2ms
memory: 7796kb
input:
2 0 11
output:
Yes
result:
ok answer is YES
Test #3:
score: 0
Accepted
time: 2ms
memory: 7704kb
input:
3 1 10 011
output:
Yes
result:
ok answer is YES
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 7624kb
input:
4 1 11 101 0101
output:
Yes
result:
wrong answer expected NO, found YES