QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#21954 | #2833. Hamilton | WhybullYMe# | WA | 3ms | 3704kb | C++14 | 1.5kb | 2022-03-08 18:58:23 | 2022-05-08 04:19:50 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
int n,a[2001][2001];
vector<pair<int,int> > v;
int main()
{
while(cin>>n)
{
v.clear();
for(int i=1;i<=n;++i)
for(int j=1;j<=n;++j)
{
a[i][j]=getchar()^48;
while(a[i][j]<0||a[i][j]>1)
a[i][j]=getchar()^48;
}
v.push_back({1,a[1][2]});
v.push_back({2,a[2][3]});
v.push_back({3,a[3][1]});
for(int i=4;i<=n;++i)
{
int pos=0;
for(int j=0;j<(int)v.size();++j)
if(v[j].second^v[(j+1)%(i-1)].second)
{
pos=j;
break;
}
int val=a[i][v[(pos+1)%(i-1)].first];
if(val==v[pos].second)
{
v[(pos+1)%(i-1)].second=val;
v.insert(v.begin()+(pos+2)%(i-1),{i,a[i][v[(pos+2)%(i-1)].first]});
}
else
{
v.insert(v.begin()+(pos+1)%(i-1),{i,val});
v[pos].second=a[i][v[pos].first];
}
}
int pos=0;
for(int i=0;i<n;++i)
if(v[i].second^v[(i+1)%n].second)
{
pos=i;
break;
}
for(int i=0;i<n;++i)
cout<<v[(i+pos)%n].first<<" ";
cout<<'\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 3704kb
input:
3 001 000 100 4 0000 0000 0000 0000
output:
2 3 1 1 2 4 3
result:
wrong answer case #1: found 2 indices