QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#817835 | #2364. Endgame | ucup-team3723# | WA | 64ms | 13408kb | C++20 | 2.8kb | 2024-12-17 13:15:31 | 2024-12-17 13:15:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) cerr << #x << ':' << (x) << endl;
#define ALL(x) x.begin(),x.end()
using ll = long long;
using ld = long double;
#define sq(x) (ll(x) * (x))
int main()
{
ll n;
cin >> n;
int ax,ay,bx,by;
cin >> ax >> ay >> bx >> by;
--ax; --ay; --bx; --by;
vector<int> dx(n), dy(n);
for (int i = 0; i < n; ++i) cin >> dx[i] >> dy[i];
// alice
set<pair<int,int>> st;
for (int i = 0; i < n; ++i) {
int nx = ax + dx[i];
int ny = ay + dy[i];
if (!(0 <= nx && nx < n && 0 <= ny && ny < n)) continue;
st.emplace(nx, ny);
}
for (int i = 0; i < n; ++i) {
int nx = bx - dx[i];
int ny = by - dy[i];
if (st.count({nx, ny})) {
cout << "Alice wins\n";
return 0;
}
}
if (n * n <= 1e7)
{
vector<vector<bool>> used(n, vector<bool> (n, true));
used[bx][by] = 0;
for (int i = 0; i < n; ++i)
{
int nx = bx + dx[i], ny = by + dy[i];
if (!(0 <= nx && nx < n && 0 <= ny && ny < n)) continue;
used[nx][ny] = 0;
}
for (int i = 0; i < n; ++i)
{
for (int j = i; j < n; ++j)
{
int nx = bx + dx[i] + dx[j], ny = by + dy[i] + dy[j];
if (!(0 <= nx && nx < n && 0 <= ny && ny < n)) continue;
used[nx][ny] = 0;
}
}
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < n; ++j)
{
if (used[i][j])
{
cout << "tie " << i + 1 << ' ' << j + 1 << endl;
return 0;
}
}
}
cout << "Bob wins" << endl;
}
else {
unordered_set<ll> p;
for (int i = 0; i < n; ++i) {
int nx = bx + dx[i], ny = by + dy[i];
if (!(0 <= nx && nx < n && 0 <= ny && ny < n)) continue;
p.insert( nx * n + ny );
}
mt19937 rnd;
bool ans = 0;
for (int t = 0; t < 100; ++t) {
int x = rnd() % n;
int y = rnd() % n;
ans = 1;
for (int i = 0; i < n; ++i)
{
int nx = bx - dx[i], ny = by - dy[i];
if (!(0 <= nx && nx < n && 0 <= ny && ny < n)) continue;
if (p.count(nx * n + ny))
{
ans = 0;
break;
}
}
if (ans)
{
cout << "tie " << x + 1 << ' ' << y + 1 << endl;
return 0;
}
}
cout << "Bob wins" << endl;
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3512kb
input:
3 2 3 1 3 1 0 0 -1 1 -1
output:
Bob wins
result:
ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
3 3 3 1 1 1 0 1 1 0 1
output:
Bob wins
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
3 2 2 3 1 -1 0 -1 1 0 1
output:
Bob wins
result:
ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
5 2 1 1 2 -2 2 1 -1 1 1 2 2 3 3
output:
tie 1 1
result:
ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
2 1 1 1 2 1 -1 1 1
output:
tie 1 1
result:
ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3764kb
input:
3 1 2 2 1 2 -2 -1 1 -2 2
output:
tie 1 1
result:
ok
Test #7:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
2 2 2 1 1 1 1 1 0
output:
tie 1 2
result:
ok
Test #8:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
2 1 1 2 2 -1 -1 1 0
output:
tie 1 2
result:
ok
Test #9:
score: 0
Accepted
time: 64ms
memory: 13228kb
input:
100000 2 100000 1 100000 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 0 17 0 18 0 19 0 20 0 21 0 22 0 23 0 24 0 25 0 26 0 27 0 28 0 29 0 30 0 31 0 32 0 33 0 34 0 35 0 36 0 37 0 38 0 39 0 40 0 41 0 42 0 43 0 44 0 45 0 46 0 47 0 48 0 49 0 50 0 51 0 52 0 53 0 54 0 55 0 56 0 57 0...
output:
tie 11613 69303
result:
ok
Test #10:
score: 0
Accepted
time: 49ms
memory: 13408kb
input:
100000 2 1 1 1 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 0 17 0 18 0 19 0 20 0 21 0 22 0 23 0 24 0 25 0 26 0 27 0 28 0 29 0 30 0 31 0 32 0 33 0 34 0 35 0 36 0 37 0 38 0 39 0 40 0 41 0 42 0 43 0 44 0 45 0 46 0 47 0 48 0 49 0 50 0 51 0 52 0 53 0 54 0 55 0 56 0 57 0 58 0 59 0...
output:
tie 11613 69303
result:
ok
Test #11:
score: -100
Wrong Answer
time: 50ms
memory: 13388kb
input:
100000 1 2 1 1 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 0 17 0 18 0 19 0 20 0 21 0 22 0 23 0 24 0 25 0 26 0 27 0 28 0 29 0 30 0 31 0 32 0 33 0 34 0 35 0 36 0 37 0 38 0 39 0 40 0 41 0 42 0 43 0 44 0 45 0 46 0 47 0 48 0 49 0 50 0 51 0 52 0 53 0 54 0 55 0 56 0 57 0 58 0 59...
output:
tie 11613 69303
result:
wrong answer Bob can capture coordinates in author's output