QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#451034#2833. Hamiltongrass8cow#WA 0ms3992kbC++17639b2024-06-22 20:36:232024-06-22 20:36:23

Judging History

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

  • [2024-06-22 20:36:23]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3992kb
  • [2024-06-22 20:36:23]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n;
char a[2010][2010];
int p[2010];
mt19937 rnd(time(0));
void sol(){
    for(int i=1;i<=n;i++)scanf("%s",a[i]+1);
    for(int o=0;o<2;o++){
        for(int i=1;i<=n;i++)p[i]=i;
        int ste=2000;
        while(ste--){
            shuffle(p+1,p+n+1,rnd);
            bool gg=0;
            for(int i=1;i<n;i++)if(a[p[i]][p[i+1]]-'0'!=o)gg=1;
            if(!gg){
                for(int i=1;i<=n;i++)printf("%d ",p[i]);
                puts("");return;
            }
        }
    }
    puts("-1");
}
int main(){
    while(~scanf("%d",&n))sol();
    return 0;
}

詳細信息

Test #1:

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

input:

3
001
000
100
4
0000
0000
0000
0000

output:

1 2 3 
1 3 2 4 

result:

ok 2 cases.

Test #2:

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

input:

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

output:

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

result:

ok 4 cases.

Test #3:

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

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 4 1 3 
1 2 3 4 
2 4 1 3 
-1
1 3 4 2 
3 2 4 1 
2 4 1 3 
-1
1 3 4 2 
4 2 3 1 
1 4 3 2 

result:

wrong answer case #4: user does not find a solution