QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#375632#2833. Hamiltonwjh213WA 0ms3584kbC++14780b2024-04-03 14:23:312024-04-03 14:23:32

Judging History

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

  • [2024-04-03 14:23:32]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3584kb
  • [2024-04-03 14:23:31]
  • 提交

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;
			}
		}
		if(n<=3){
			for(int i=1;i<=n;i++){
				cout<<i<<" ";
			}
			cout<<"\n";
			continue;
		}
		vector<int> V{1,2,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;
			}
			if(fl){
				V.push_back(i);
				continue;
			}
			int now=a[V[ind]][i];
			if(now==a[V[ind-1]][V[ind]])V.insert(V.begin()+ind+1,now);
			else V.insert(V.begin()+ind,now);
		}
		for(auto it:V){
			cout<<it<<" ";
		}
		cout<<"\n";
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3584kb

input:

3
001
000
100
4
0000
0000
0000
0000

output:

1 2 3 
1 2 3 4 

result:

ok 2 cases.

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3532kb

input:

3
000
000
000
3
010
100
000
3
011
100
100
3
011
101
110

output:

1 2 3 
1 2 3 
1 2 3 
1 2 3 

result:

wrong answer case #3: found 2 indices