QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#375601 | #2833. Hamilton | World_Creater | WA | 1ms | 3656kb | C++14 | 841b | 2024-04-03 14:02:03 | 2024-04-03 14:02:03 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,nxt[2005],lst[2005];
char mp[2005][2005];
int main()
{
while(cin>>n)
{
for(int i=1;i<=n;i++)
{
cin>>mp[i]+1;
for(int j=1;j<=n;j++)
{
mp[i][j]-='0';
}
}
nxt[1]=2;
lst[2]=1;
nxt[2]=1;
lst[1]=2;
int pos=2;
for(int i=3;i<=n;i++)
{
if(mp[pos][i]==mp[pos][nxt[pos]])
{
nxt[i]=nxt[pos];
lst[nxt[pos]]=i;
lst[i]=pos;
nxt[pos]=i;
}
else
{
lst[i]=lst[pos];
nxt[lst[pos]]=i;
nxt[i]=pos;
lst[pos]=i;
}
for(int j=1;j<=i&&mp[pos][nxt[pos]]==mp[pos][lst[pos]];j++)
{
if(mp[j][nxt[j]]!=mp[j][lst[j]]) pos=j;
}
}
for(int i=pos;;i=nxt[i])
{
cout<<i<<" ";
if(nxt[i]==pos) break ;
}
cout<<"\n";
for(int i=1;i<=n+1;i++) nxt[i]=lst[i]=0;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3628kb
input:
3 001 000 100 4 0000 0000 0000 0000
output:
1 2 3 2 4 3 1
result:
ok 2 cases.
Test #2:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
3 000 000 000 3 010 100 000 3 011 100 100 3 011 101 110
output:
2 3 1 2 1 3 2 1 3 2 3 1
result:
ok 4 cases.
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3656kb
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:
2 4 3 1 2 3 1 4 1 2 3 4 2 1 3 4 2 1 3 4 3 1 2 4 2 4 3 1 2 1 3 4 1 4 2 3 2 1 3 4 1 4 2 3
result:
wrong answer case #9: found 3 indices