QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#228758#7636. Fair Electionsucup-team022#RE 0ms3700kbC++17738b2023-10-28 14:08:402023-10-28 14:08:41

Judging History

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

  • [2023-10-28 14:08:41]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3700kb
  • [2023-10-28 14:08:40]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
typedef array<int, 3> arr;
int n;
arr a[10005], cur;
int Get(arr res) {
	for (int i = 0; i < 3; i++) {
		bool ok = 1;
		for (int j = 0; j < 3; j++) {
			if (res[i] < res[j]) ok = 0;
		}
		if (ok) return i;
	}
	assert(0);
	return -1;
}
arr dfs(int x) {
	if (x == n + 1) {
		return cur;
	}
	for (int j = 0; j < 3; j++) {
		cur[a[x][j]]++;
		auto res = dfs(x + 1);
		cur[a[x][j]]--;
		if (Get(res) == a[x][j]) {
			return res;
		}
	}
	assert(0);
	return {-1, -1, -1};
}
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < 3; j++) cin >> a[i][j], a[i][j]--;
	}
	arr res = dfs(1);
	cout << Get(res) + 1;
}

詳細信息

Test #1:

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

input:

3
3 2 1
1 2 3
2 1 3

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3688kb

input:

5
1 2 3
2 3 1
1 3 2
3 1 2
2 1 3

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

5
1 2 3
3 2 1
1 2 3
1 2 3
3 2 1

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

5
3 2 1
3 1 2
2 3 1
1 2 3
2 1 3

output:

2

result:

ok 1 number(s): "2"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

5
3 2 1
3 2 1
1 3 2
1 3 2
3 2 1

output:

3

result:

ok 1 number(s): "3"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3696kb

input:

5
3 2 1
3 1 2
1 2 3
1 3 2
1 3 2

output:

1

result:

ok 1 number(s): "1"

Test #7:

score: -100
Runtime Error

input:

20
1 2 3
2 3 1
1 3 2
3 1 2
2 1 3
1 2 3
3 2 1
1 2 3
1 2 3
3 2 1
3 2 1
3 1 2
2 3 1
1 2 3
2 1 3
3 2 1
3 2 1
1 3 2
1 3 2
3 2 1

output:


result: