QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#375988#2833. HamiltonzhouqixuanWA 1ms3888kbC++141.2kb2024-04-03 19:21:032024-04-03 19:21:04

Judging History

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

  • [2024-04-03 19:21:04]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3888kb
  • [2024-04-03 19:21:03]
  • 提交

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3888kb

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: 3800kb

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