| Task: | Peli |
| Sender: | rottis |
| Submission time: | 2026-01-17 14:26:20 +0200 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | 100 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 17 |
| #2 | ACCEPTED | 38 |
| #3 | ACCEPTED | 45 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.04 s | 1, 2, 3 | details |
| #2 | ACCEPTED | 0.04 s | 1, 2, 3 | details |
| #3 | ACCEPTED | 0.04 s | 2, 3 | details |
| #4 | ACCEPTED | 0.04 s | 3 | details |
| #5 | ACCEPTED | 0.04 s | 2, 3 | details |
| #6 | ACCEPTED | 0.04 s | 3 | details |
Code
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
int ans[2001][2001];
bool col_has_other[2001];
bool row_has_other[2001];
bool diag_has_other[4002];
const int SELF = 1;
const int OTHER = 2;
const int MAX = 2000;
inline int mini(int a, int b) {
return a < b ? a : b;
}
inline int maxi(int a, int b) {
return a > b ? a : b;
}
void set_other(int a, int b) {
ans[a][b] = OTHER;
col_has_other[a] = true;
row_has_other[b] = true;
diag_has_other[a-b+MAX] = true;
}
bool has_other(int a, int b) {
return col_has_other[a] || row_has_other[b] || diag_has_other[a-b+MAX];
}
int main() {
cin.tie(NULL);
ios_base::sync_with_stdio(false);
cin >> n;
for (int a = 0; a <= MAX; a++) {
for (int b = 0; b <= MAX; b++) {
if (a == 0 || b == 0) {
ans[a][b] = SELF;
} else if (a == b) {
ans[a][b] = SELF;
} else if ((a == 1 && b == 2) || (a == 2 && b == 1)) {
set_other(a, b);
} else if (has_other(a, b)) {
ans[a][b] = SELF;
} else {
set_other(a, b);
}
}
}
// tilanne 1, 1 on voittava sille kuka pelaa seuraavaksi
// kaikki tilanteet n, n myös voittavia
// tilanteet 1, 2 ja 2, 1 ovat häviäviä
// n, 2 pakottaa voittavan tilanteen (n >= 3) jos tekee tilanteen 1, 2
// n, 3 pakottaa voittavan tilanteen (n >= 3): 4, 1
for (int i = 0; i < n; i++) {
int a, b;
cin >> a >> b;
//if (b < a) swap(a, b);
cout << (ans[a][b] == SELF ? "first\n" : "second\n");
}
return 0;
}Test details
Test 1 (public)
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 5 2 2 1 2 3 2 4 3 ... |
| correct output |
|---|
| first second first first second |
| user output |
|---|
| first second first first second |
Test 2
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 100 1 1 1 2 1 3 1 4 ... |
| correct output |
|---|
| first second first first first ... |
| user output |
|---|
| first second first first first ... |
Test 3
Group: 2, 3
Verdict: ACCEPTED
| input |
|---|
| 1000 82 14 91 84 13 97 92 23 ... |
| correct output |
|---|
| first first first first first ... |
| user output |
|---|
| first first first first first ... |
Test 4
Group: 3
Verdict: ACCEPTED
| input |
|---|
| 1000 1630 271 1812 1671 254 1938 1827 443 ... |
| correct output |
|---|
| first first first first first ... |
| user output |
|---|
| first first first first first ... |
Test 5
Group: 2, 3
Verdict: ACCEPTED
| input |
|---|
| 1000 36 14 79 81 93 82 32 1 ... |
| correct output |
|---|
| first first first first first ... |
| user output |
|---|
| first first first first first ... |
Test 6
Group: 3
Verdict: ACCEPTED
| input |
|---|
| 1000 486 300 899 1455 879 543 40 65 ... |
| correct output |
|---|
| second second second second second ... |
| user output |
|---|
| second second second second second ... |
