QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#228758 | #7636. Fair Elections | ucup-team022# | RE | 0ms | 3700kb | C++17 | 738b | 2023-10-28 14:08:40 | 2023-10-28 14:08:41 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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