QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#21950 | #2833. Hamilton | WhybullYMe# | WA | 3ms | 3620kb | C++14 | 1.5kb | 2022-03-08 18:53:50 | 2022-05-08 04:19:15 |
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=v[pos].second;
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: 100
Accepted
time: 2ms
memory: 3620kb
input:
3 001 000 100 4 0000 0000 0000 0000
output:
1 2 3 1 2 4 3
result:
ok 2 cases.
Test #2:
score: 0
Accepted
time: 3ms
memory: 3576kb
input:
3 000 000 000 3 010 100 000 3 011 100 100 3 011 101 110
output:
1 2 3 2 3 1 3 1 2 1 2 3
result:
ok 4 cases.
Test #3:
score: -100
Wrong Answer
time: 3ms
memory: 3544kb
input:
4 0000 0000 0000 0000 4 0000 0001 0000 0100 4 0100 1010 0100 0000 4 0111 1000 1000 1000 4 0010 0011 1101 0110 4 0111 1011 1100 1100 4 0111 1011 1101 1110 4 0000 0011 0101 0110 4 0101 1010 0100 1000 4 0011 0011 1100 1100 4 0010 0001 1000 0100
output:
1 2 4 3 2 3 1 4 2 4 3 1 4 2 3 1 4 2 3 1 1 2 4 3 1 2 4 3 4 2 3 1 2 4 3 1 1 4 2 3 4 1 2 3
result:
wrong answer case #6: found 2 indices