QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#861189 | #8830. Breaking Bad | Crying | WA | 0ms | 3712kb | C++14 | 1.1kb | 2025-01-18 16:26:24 | 2025-01-18 16:30:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1010,M = 5;
int n,a[N][N],ans[M];
void exr(int x,int y){
for(int i=1;i<=n;i++)swap(a[x][i],a[y][i]);
}
void exc(int x,int y){
for(int i=1;i<=n;i++)swap(a[i][x],a[i][y]);
}
void calc(int r){
if(r>2*M){
for(int i=0;i<M;i++)cout<<"Y";
exit(0);
}
for(int i=r+1;i<=n;i++){
int d = a[r][i] - a[r][i-1],flag = 1;
for(int j=r+1;j<=n;j++)if(a[j][i] - a[j][i-1] != d){
exr(j,r+1);
exc(r,i-1); exc(r+1,i);
return calc(r+2);
}
}
int pre = 0,cnt = r/2;
for(int i=r;i<=n;i++)pre = (pre+a[i][i])%M;
for(int S=0;S<(1<<cnt);S++){
int sum = pre;
for(int x=0;x<cnt;x++){
int id = 2*x+1;
sum = (sum+a[id][id+(S>>x&1)]+a[id+1][id+!(S>>x&1)])%M;
}
ans[sum] = 1;
}
}
int main(){
ios::sync_with_stdio(false); cin.tie(0);
cin>>n;
for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)cin>>a[i][j];
calc(1);
for(int i=0;i<M;i++)if(ans[i])cout<<"Y"; else cout<<"N";
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3712kb
input:
2 0 4 4 0
output:
YNNYN
result:
ok "YNNYN"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
2 1 1 1 1
output:
NNYNN
result:
ok "NNYNN"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3712kb
input:
4 0 0 1 0 0 1 0 1 0 0 0 0 1 1 0 0
output:
YYNNN
result:
wrong answer 1st words differ - expected: 'YYYYN', found: 'YYNNN'