QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#375599 | #2833. Hamilton | World_Creater | WA | 1ms | 3572kb | C++14 | 841b | 2024-04-03 14:01:05 | 2024-04-03 14:01:05 |
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: 0
Wrong Answer
time: 1ms
memory: 3572kb
input:
3 001 000 100 4 0000 0000 0000 0000
output:
2 3 1 4 1 2 3
result:
wrong answer case #1: found 2 indices