QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#451079#2833. Hamiltongrass8cow#WA 0ms3820kbC++17804b2024-06-22 20:54:162024-06-22 20:54:17

Judging History

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

  • [2024-06-22 20:54:17]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3820kb
  • [2024-06-22 20:54:16]
  • 提交

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-2;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 j=1;j<i;j++)printf("%c",a[p[j]][p[j+1]]);puts("");
    }
    if(a[p[n-1]][p[n]]==a[p[n]][p[1]]){for(int i=1;i<=n;i++)printf("%d ",p[i]);puts("");}
    else{printf("%d ",p[n]);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: 3820kb

input:

3
001
000
100
4
0000
0000
0000
0000

output:

0
00
1 3 2 
0
00
000
4 3 2 1 

result:

wrong answer case #1: p[1] out of bound