QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#375682#2833. Hamiltonwjh213WA 1ms3532kbC++141.4kb2024-04-03 14:50:082024-04-03 14:50:08

Judging History

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

  • [2024-04-03 14:50:08]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3532kb
  • [2024-04-03 14:50:08]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int const MAX=2005;
bool a[MAX][MAX];
signed main(){
	int n;
	while(cin>>n){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				char c;
				cin>>c;
				a[i][j]=c=='1'?1:0;
			}
		}
		//vector<int> V{1,2,3};
		deque<int> Q;
		Q.push_back(1);
		Q.push_back(2);
		Q.push_back(3);
		for(int i=4;i<=n;i++){
			bool fl=true;//ind=0;
			//for(int j=1;j+1<V.size();j++){
			//	if(a[V[j]][V[j+1]]!=a[V[j-1]][V[j]])fl=false,ind=j;
			//}
			int miao=-1;
			int las=Q.front();
			Q.pop_front();
			for(int j=1;j<i;j++){
				int now=Q.front();
				Q.pop_front();
				if(miao==-1)miao=a[las][now];
				else if(a[las][now]!=miao){
					fl=false;
					Q.push_front(now);
					break;
				}
				Q.push_back(las);
				las=now;
			}
			if(fl){
				Q.push_front(las);
				Q.push_back(i);
				continue;
			}
			int now=a[las][i];
			if(now==a[las][Q.front()])Q.push_back(i);
			else Q.push_front(i);
			Q.push_back(las);
		}
		//for(auto it:V){
		//	cout<<it<<" ";
		//}
		//cout<<"\n";
		int las=Q.front();
		Q.pop_front();
		int miao=-1;
		for(int i=1;i<=n;i++){
			int now=Q.front();
			Q.pop_front();
			if(miao==-1){
				miao=a[now][las];
			}else{
				Q.push_front(now);
				break;
			}
			Q.push_back(las);
			las=now;
		}
		Q.push_front(las);
		while(!Q.empty()){
			cout<<Q.front()<<" ";
			Q.pop_front();
		}
		cout<<"\n";
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3532kb

input:

3
001
000
100
4
0000
0000
0000
0000

output:

2 3 1 
2 3 4 1 

result:

wrong answer case #1: found 2 indices