QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#451073#2833. Hamiltongrass8cow#WA 0ms3972kbC++17733b2024-06-22 20:52:112024-06-22 20:52:11

Judging History

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

  • [2024-06-22 20:52:11]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3972kb
  • [2024-06-22 20:52:11]
  • 提交

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);
    }
    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;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3920kb

input:

3
001
000
100
4
0000
0000
0000
0000

output:

3 2 1 
2 3 4 1 

result:

ok 2 cases.

Test #2:

score: 0
Accepted
time: 0ms
memory: 3784kb

input:

3
000
000
000
3
010
100
000
3
011
100
100
3
011
101
110

output:

2 3 1 
2 1 3 
2 1 3 
1 2 3 

result:

ok 4 cases.

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3972kb

input:

4
0000
0000
0000
0000
4
0000
0001
0000
0100
4
0100
1010
0100
0000
4
0111
1000
1000
1000
4
0010
0011
1101
0110
4
0111
1011
1100
1100
4
0111
1011
1101
1110
4
0000
0011
0101
0110
4
0101
1010
0100
1000
4
0011
0011
1100
1100
4
0010
0001
1000
0100

output:

2 3 4 1 
2 3 4 1 
1 2 4 3 
2 1 4 3 
2 4 1 3 
3 1 2 4 
1 2 3 4 
2 3 4 1 
1 2 4 3 
3 2 1 4 
3 2 4 1 

result:

wrong answer case #5: found 2 indices