QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#451060 | #2833. Hamilton | grass8cow# | WA | 0ms | 3892kb | C++17 | 618b | 2024-06-22 20:49:27 | 2024-06-22 20:49:27 |
Judging History
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);
}
for(int i=1;i<=n;i++)printf("%d ",p[i]);puts("");
}
int main(){
while(~scanf("%d",&n))sol();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3892kb
input:
3 001 000 100 4 0000 0000 0000 0000
output:
2 1 3 2 3 4 1
result:
wrong answer case #1: found 2 indices