QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#710334#8830. Breaking Baducup-team134WA 805ms6040kbC++141.4kb2024-11-04 19:28:592024-11-04 19:28:59

Judging History

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

  • [2024-11-04 19:28:59]
  • 评测
  • 测评结果:WA
  • 用时:805ms
  • 内存:6040kb
  • [2024-11-04 19:28:59]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int N=1050;
int a[N][N],b[N][N],n,p[N],q[N];

mt19937 rng(time(0));
void Shuffle(){
    iota(p+1,p+1+n,1);
    shuffle(p+1,p+1+n,rng);
    iota(q+1,q+1+n,1);
    shuffle(q+1,q+1+n,rng);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            b[i][j]=a[p[i]][q[j]];
        }
    }
}

int Combine(int a,int b){
    int ans=0;
    for(int i=0;i<5;i++)if(a>>i&1){
        for(int j=0;j<5;j++)if(b>>j&1){
            ans|=(1<<((i+j)%5));
        }
    }
    return ans;
}

int Solve(int xl,int xr,int yl,int yr){
    if(xl==xr || yl==yr){
        if(xl>n && yl>n){
            return 1;
        }
        if(xl<=n && yl<=n){
            return b[xl][yl];
        }
        return 0;
    }
    int xm=xl+xr>>1;
    int ym=yl+yr>>1;
    int A=Solve(xl,xm,yl,ym);
    int B=Solve(xl,xm,ym+1,yr);
    int C=Solve(xm+1,xr,yl,ym);
    int D=Solve(xm+1,xr,ym+1,yr);
    return Combine(A,D)|Combine(B,C);
}
int main(){
    scanf("%i",&n);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            scanf("%i",&a[i][j]);
        }
    }
    int ans=0;
    while(clock()<0.8*CLOCKS_PER_SEC){
        Shuffle();
        ans|=Solve(1,1024,1,1024);
    }
    for(int i=0;i<5;i++){
        if(ans>>i&1)printf("Y");
        else printf("N");
    }
    printf("\n");
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 805ms
memory: 6040kb

input:

2
0 4
4 0

output:

NNNNY

result:

wrong answer 1st words differ - expected: 'YNNYN', found: 'NNNNY'