QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#710306#8830. Breaking Baducup-team134WA 772ms6036kbC++141.3kb2024-11-04 19:22:572024-11-04 19:22:59

Judging History

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

  • [2024-11-04 19:22:59]
  • 评测
  • 测评结果:WA
  • 用时:772ms
  • 内存:6036kb
  • [2024-11-04 19:22:57]
  • 提交

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)return 1;
    if(xl==xr && yl==yr){
        return 1<<b[xl][yl];
    }
    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,n,1,n);
    }
    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: 100
Accepted
time: 431ms
memory: 5876kb

input:

2
0 4
4 0

output:

YNNYN

result:

ok "YNNYN"

Test #2:

score: 0
Accepted
time: 395ms
memory: 5940kb

input:

2
1 1
1 1

output:

NNYNN

result:

ok "NNYNN"

Test #3:

score: 0
Accepted
time: 616ms
memory: 5928kb

input:

4
0 0 1 0
0 1 0 1
0 0 0 0
1 1 0 0

output:

YYYYN

result:

ok "YYYYN"

Test #4:

score: 0
Accepted
time: 569ms
memory: 6020kb

input:

4
0 0 0 1
0 1 0 1
1 0 0 0
0 1 0 0

output:

YYYYN

result:

ok "YYYYN"

Test #5:

score: -100
Wrong Answer
time: 772ms
memory: 6036kb

input:

10
1 4 2 0 0 2 0 1 3 3
0 3 1 4 4 1 4 0 2 2
1 4 2 0 0 2 0 1 0 3
0 3 1 4 4 1 4 0 2 2
4 2 0 3 3 0 3 4 1 1
2 0 3 1 1 3 1 2 4 4
4 2 0 3 3 0 3 4 1 1
2 0 3 1 1 3 1 2 4 4
1 4 2 0 0 2 0 1 3 3
3 1 4 2 2 4 2 3 0 0

output:

YYYYY

result:

wrong answer 1st words differ - expected: 'NYNNY', found: 'YYYYY'