QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#375988 | #2833. Hamilton | zhouqixuan | WA | 1ms | 3888kb | C++14 | 1.2kb | 2024-04-03 19:21:03 | 2024-04-03 19:21:04 |
Judging History
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