QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#375674#2833. Hamilton369PaiWA 0ms3508kbC++141.0kb2024-04-03 14:46:592024-04-03 14:47:01

Judging History

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

  • [2024-04-03 14:47:01]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3508kb
  • [2024-04-03 14:46:59]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2005;
int n , a[N][N];
int Solve()
{
	for(int i = 1 ; i <= n ; i++)
	{
		string s; cin >> s;
		for(int j = 0 ; j < n ; j++)
			a[i][j + 1] = s[j] - '0';
	}
	vector<int>p = {1};
	for(int i = 1 ; i < n ; i++)
	{
		int k = i + 1; bool ok = 0;
		for(int j = 0 ; j < i ; j++)
		{
			int x = p[j] , y = p[(j + 1) % i] , z = p[(j + 2) % i];
			if(a[x][y] != a[y][z])
			{
				if(a[y][k] == a[y][z])p.insert(p.begin() + (j + 1) % i, k);
				else p.insert(p.begin() + (j + 2) % i , k);
				ok = 1; break ;
			}
		}
		if(!ok)p.push_back(k);
	}
	for(int j = 0 ; j < n ; j++)
	{
		int x = p[j] , y = p[(j + 1) % n] , z = p[(j + 2) % n];
		if(a[x][y] != a[y][z])
		{
			for(int k = (j + 1) % n ; k < n ; k++)cout << p[k] << " ";
			for(int k = 0 ; k <= j ; k++)cout << p[k] << " ";
			break ;
		}
	}
	cout << "\n";
	return 0;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0) , cout.tie(0);
	while(cin >> n)Solve();
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3508kb

input:

3
001
000
100
4
0000
0000
0000
0000

output:

3 1 2 


result:

wrong output format Unexpected end of file - int32 expected