QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#375669#2833. Hamilton369PaiWA 0ms3636kbC++14818b2024-04-03 14:44:152024-04-03 14:44:15

Judging History

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

  • [2024-04-03 14:44:15]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3636kb
  • [2024-04-03 14:44:15]
  • 提交

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 x : p)cout << x << " ";
	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: 100
Accepted
time: 0ms
memory: 3564kb

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: 3636kb

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