QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#375599#2833. HamiltonWorld_CreaterWA 1ms3572kbC++14841b2024-04-03 14:01:052024-04-03 14:01:05

Judging History

你现在查看的是最新测评结果

  • [2024-04-03 14:01:05]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3572kb
  • [2024-04-03 14:01:05]
  • 提交

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