QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#451060#2833. Hamiltongrass8cow#WA 0ms3892kbC++17618b2024-06-22 20:49:272024-06-22 20:49:27

Judging History

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

  • [2024-06-22 20:49:27]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3892kb
  • [2024-06-22 20:49:27]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n;
char a[2010][2010];
int p[2010];
void ins(int x,int z){
    for(int i=n;i>=x+2;i--)p[i]=p[i-1];
    p[x+1]=z;
}
void sol(){
    for(int i=1;i<=n;i++)scanf("%s",a[i]+1),p[i]=0;
    p[1]=1;
    for(int i=2;i<=n;i++){
        int t=1;
        for(int j=2;j<i;j++)if(a[p[j-1]][p[j]]!=a[p[j]][p[j+1]]){t=j;break;}
        if(t==1&&i>=3&&a[p[1]][p[2]]=='1')t=i-1;
        if(a[p[t]][i]=='0')ins(t-1,i);
        else ins(t,i);
    }
    for(int i=1;i<=n;i++)printf("%d ",p[i]);puts("");
}
int main(){
    while(~scanf("%d",&n))sol();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3892kb

input:

3
001
000
100
4
0000
0000
0000
0000

output:

2 1 3 
2 3 4 1 

result:

wrong answer case #1: found 2 indices