QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#375983#2833. HamiltonzhouqixuanWA 0ms3884kbC++141.2kb2024-04-03 19:15:582024-04-03 19:15:59

Judging History

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

  • [2024-04-03 19:15:59]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3884kb
  • [2024-04-03 19:15:58]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=2010;
int n;
char c[N][N];
int ne[N];
void insert(int x,int k){
    int t=ne[x];
    ne[x]=k,ne[k]=t;
    return;
}
void calc(){
    for(int i=1;i<=n;i++) ne[i]=0;
    ne[1]=1;
    for(int l=2;l<=n;l++){
        int t1=0,t0=0;
        for(int i=1;;i=ne[i]){
            if(c[i][ne[i]]=='0') t0=1;
            else t1=1;
            // cout<<"!"<<i<<" "<<ne[i]<<" "<<c[i][ne[i]]<<endl;
            if(ne[i]==1) break;
        }
        // cout<<t0<<" "<<t1<<endl;
        if(t1+t0==1) insert(1,l);
        else{
            // cout<<l<<endl;
            for(int i=1;;i=ne[i]){
                int j=ne[i];int k=ne[j];
                if(c[i][j]==1 && c[j][k]==0){
                    if(c[j][l]=0) insert(i,l);
                    else insert(j,l);
                    break;
                }
            }
        }
    }
    for(int i=1;;i=ne[i]){
        printf("%d ",i);
        if(ne[i]==1) break;
    }
    puts("");
    return;
}
int main(){
    while(scanf("%d",&n)!=-1){
        for(int i=1;i<=n;i++) scanf("%s",c[i]+1);
        calc();
    }
    return 0;
}

详细

Test #1:

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

input:

3
001
000
100
4
0000
0000
0000
0000

output:

1 3 2 
1 4 3 2 

result:

ok 2 cases.

Test #2:

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

input:

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

output:

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

result:

wrong answer case #3: found 2 indices