QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#861189#8830. Breaking BadCryingWA 0ms3712kbC++141.1kb2025-01-18 16:26:242025-01-18 16:30:14

Judging History

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

  • [2025-01-18 16:30:14]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3712kb
  • [2025-01-18 16:26:24]
  • 提交

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'