QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#375632 | #2833. Hamilton | wjh213 | WA | 0ms | 3584kb | C++14 | 780b | 2024-04-03 14:23:31 | 2024-04-03 14:23:32 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int const MAX=2005;
bool a[MAX][MAX];
signed main(){
int n;
while(cin>>n){
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
char c;
cin>>c;
a[i][j]=c=='1'?1:0;
}
}
if(n<=3){
for(int i=1;i<=n;i++){
cout<<i<<" ";
}
cout<<"\n";
continue;
}
vector<int> V{1,2,3};
for(int i=4;i<=n;i++){
bool fl=true,ind=0;
for(int j=1;j+1<V.size();j++){
if(a[V[j]][V[j+1]]!=a[V[j-1]][V[j]])fl=false,ind=j;
}
if(fl){
V.push_back(i);
continue;
}
int now=a[V[ind]][i];
if(now==a[V[ind-1]][V[ind]])V.insert(V.begin()+ind+1,now);
else V.insert(V.begin()+ind,now);
}
for(auto it:V){
cout<<it<<" ";
}
cout<<"\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3584kb
input:
3 001 000 100 4 0000 0000 0000 0000
output:
1 2 3 1 2 3 4
result:
ok 2 cases.
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3532kb
input:
3 000 000 000 3 010 100 000 3 011 100 100 3 011 101 110
output:
1 2 3 1 2 3 1 2 3 1 2 3
result:
wrong answer case #3: found 2 indices