QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#137396 | #2353. Maharajas are Going Home | S_Explosion# | WA | 531ms | 120568kb | C++20 | 2.9kb | 2023-08-10 11:57:13 | 2023-08-10 11:58:09 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <assert.h>
#include <bitset>
template <typename Tp>
inline void read(Tp &x) {
x = 0;
bool f = true; char ch = getchar();
for ( ; ch < '0' || ch > '9'; ch = getchar()) f ^= ch == '-';
for ( ; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + (ch ^ 48);
x = f ? x : -x;
}
const int N = 2e3;
int SG[N + 5][N + 5], x[N + 5], y[N + 5];
std::bitset<N * 2 + 5> col[N + 5], row[N + 5], diag[N * 2 + 5], cur;
int p1[N + 5][N * 2 + 5], p2[N + 5][N * 2 + 5], p3[N * 2 + 5][N * 2 + 5];
void solve(int x, int y) {
if (x == 1) {
SG[x][y] = y - 1;
}
else if (y == 1) {
SG[x][y] = x - 1;
}
else {
int v1 = 2 * N + 1, v2 = 2 * N + 1;
if (x > 2 && y > 1) v1 = SG[x - 2][y - 1];
if (x > 1 && y > 2) v2 = SG[x - 1][y - 2];
cur = row[x] & col[y] & diag[x - y + N];
cur[v1] = cur[v2] = 0;
SG[x][y] = (int)cur._Find_first();
}
row[x][SG[x][y]] = col[y][SG[x][y]] = diag[x - y + N][SG[x][y]] = 0;
// if (x <= 10 && y <= 10) printf("%d %d %d\n", x, y, SG[x][y]);
if (!p1[x][SG[x][y]]) p1[x][SG[x][y]] = y;
if (!p2[y][SG[x][y]]) p2[y][SG[x][y]] = x;
if (!p3[x - y + N][SG[x][y]]) p3[x - y + N][SG[x][y]] = y;
}
int main() {
for (int i = 1; i <= N; ++i) col[i].set(), row[i].set();
for (int i = 1; i <= 2 * N; ++i) diag[i].set();
for (int i = 1; i <= N; ++i)
for (int j = 1; j <= N; ++j) solve(i, j);
int T;
read(T);
while (T--) {
int n;
read(n);
int ans = 0;
for (int i = 1; i <= n; ++i) {
read(x[i]), read(y[i]);
ans ^= SG[x[i]][y[i]];
}
if (!ans) {
printf("-1 -1 -1\n");
continue;
}
for (int i = 1; i <= n; ++i) {
int cur = ans ^ SG[x[i]][y[i]];
int ansx = 0, ansy = 0;
if (p1[x[i]][cur] && p1[x[i]][cur] < y[i]) ansx = x[i], ansy = p1[x[i]][cur];
if (p2[y[i]][cur] && p2[y[i]][cur] < x[i]) ansx = p2[y[i]][cur], ansy = y[i];
if (p3[x[i] - y[i] + N][cur] && p3[x[i] - y[i] + N][cur] < y[i]) {
int yy = p3[x[i] - y[i] + N][cur], xx = x[i] - y[i] + yy;
if (ansx == 0 || xx <= ansx) ansx = xx, ansy = yy;
}
if (x[i] > 2 && y[i] > 1 && SG[x[i] - 2][y[i] - 1] == cur) {
if (ansx == 0 || x[i] - 2 < ansx || (x[i] - 2 == ansx && y[i] - 1 < ansy)) ansx = x[i] - 2, ansy = y[i] - 1;
}
if (x[i] > 1 && y[i] > 2 && SG[x[i] - 1][y[i] - 2] == cur) {
if (ansx == 0 || x[i] - 1 < ansx || (x[i] - 1 == ansx && y[i] - 2 < ansy)) ansx = x[i] - 1, ansy = y[i] - 2;
}
if (ansx) {
printf("%d %d %d\n", i, ansx, ansy);
break;
}
}
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 520ms
memory: 120520kb
input:
3 5 2 3 3 2 3 3 3 3 3 3 1 2 4 2 1 1 3 2
output:
3 1 1 -1 -1 -1 2 1 1
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 527ms
memory: 120276kb
input:
1 1 1 1
output:
-1 -1 -1
result:
ok single line: '-1 -1 -1'
Test #3:
score: 0
Accepted
time: 485ms
memory: 120568kb
input:
100 1 5 5 1 1 5 1 5 4 1 4 4 1 2 2 1 5 3 1 4 5 1 2 4 1 4 1 1 3 2 1 3 2 1 1 4 1 2 5 1 4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 1 1 1 3 7 1 2 4 1 1 1 1 2 4 1 1 1 1 3 7 1 5 6 1 1 1 1 5 6 1 2 4 1 4 2 1 4 2 1 1 1 1 6 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 4 1 7 3 1 4 2 1 3...
result:
ok 100 lines
Test #5:
score: 0
Accepted
time: 498ms
memory: 120564kb
input:
100 2 100 100 87 49 2 38 68 61 81 2 41 26 82 40 2 15 92 26 90 2 87 50 76 15 2 41 85 57 30 2 52 7 73 19 2 78 15 95 71 2 51 72 5 34 2 20 83 74 1 2 63 42 74 75 2 97 96 35 72 2 17 84 98 52 2 84 37 50 5 2 55 26 62 4 2 67 13 45 64 2 11 93 45 58 2 39 9 64 26 2 49 17 40 18 2 38 51 34 2 2 30 6 50 60 2 19 24 ...
output:
1 91 91 2 30 50 2 27 40 2 10 74 1 56 50 1 20 64 2 51 19 2 23 71 1 12 33 1 7 70 1 29 42 1 86 85 2 64 52 1 28 37 1 49 20 2 18 64 1 2 84 2 45 7 1 41 17 1 38 20 1 30 5 1 19 22 1 10 42 1 9 11 1 32 84 2 42 43 1 19 14 1 24 35 1 5 4 2 57 55 1 51 3 2 75 25 1 10 64 1 14 30 1 32 29 2 1 45 1 18 65 2 12 46 1 49 ...
result:
ok 100 lines
Test #6:
score: 0
Accepted
time: 494ms
memory: 120560kb
input:
100 3 200 200 131 95 32 174 3 90 177 120 177 83 162 3 139 197 56 14 151 88 3 168 34 1 13 179 181 3 119 15 123 165 132 113 3 80 198 150 34 183 118 3 15 185 187 103 6 15 3 193 42 99 155 88 9 3 1 20 19 118 130 121 3 167 54 37 116 27 84 3 8 163 136 50 96 43 3 194 145 58 50 162 188 3 169 181 192 43 167 2...
output:
1 15 15 2 20 77 1 75 133 1 166 34 2 9 51 1 19 198 1 15 47 1 126 42 3 22 121 1 52 54 1 8 29 1 60 11 1 98 110 1 88 19 3 13 112 1 29 91 1 14 4 1 4 84 1 11 58 1 55 109 2 114 112 1 10 117 2 52 15 1 4 23 1 17 75 1 39 2 1 4 185 1 64 47 1 13 145 1 66 33 1 16 55 1 137 53 1 32 9 1 146 11 3 120 69 2 48 46 3 9 ...
result:
ok 100 lines
Test #7:
score: 0
Accepted
time: 481ms
memory: 120388kb
input:
100 5 500 500 412 315 268 386 7 71 293 234 5 89 405 380 251 212 313 319 289 424 1 5 28 410 110 148 413 360 185 118 192 330 5 284 167 405 475 386 175 131 486 498 235 5 426 10 287 434 435 348 61 183 30 483 5 417 81 433 143 297 150 100 72 368 183 5 257 315 382 288 380 131 426 174 140 5 5 377 418 103 10...
output:
1 212 500 1 89 47 1 28 55 2 385 475 3 403 348 2 421 131 2 267 288 1 196 418 4 204 378 1 314 55 1 117 27 1 30 150 2 64 112 1 3 10 1 388 409 4 20 165 1 140 16 3 153 336 1 168 403 5 1 399 3 91 230 3 58 398 2 19 143 3 165 472 1 3 164 1 119 377 3 182 392 3 168 99 1 206 86 4 83 284 2 24 132 2 121 436 1 11...
result:
ok 100 lines
Test #8:
score: 0
Accepted
time: 521ms
memory: 120340kb
input:
100 8 1000 1000 131 762 404 493 235 438 648 787 905 559 178 650 236 286 8 218 483 744 690 589 895 77 2 577 355 453 405 780 760 11 198 8 862 323 144 834 503 51 908 62 814 794 213 894 455 113 323 512 8 435 880 684 150 109 541 756 458 814 763 635 375 136 601 294 735 8 427 907 16 155 36 166 796 522 99 7...
output:
2 131 176 2 676 690 5 629 609 4 13 458 2 16 111 1 73 860 1 168 327 2 875 48 5 151 141 8 128 822 1 165 363 1 402 990 3 122 716 3 174 342 2 126 217 1 544 217 7 171 338 2 58 781 5 451 163 7 30 285 1 582 686 1 340 204 2 85 447 3 40 40 1 344 646 1 24 375 1 260 217 4 338 621 1 196 384 1 384 669 1 237 439 ...
result:
ok 100 lines
Test #9:
score: -100
Wrong Answer
time: 531ms
memory: 120388kb
input:
100 10 2000 2000 1616 1893 1722 1287 1284 1348 1288 280 989 762 159 632 9 218 1263 1931 667 473 10 984 519 597 1841 896 1752 1709 369 444 1128 1931 679 452 941 1117 464 1606 1177 1417 728 10 1366 1361 1980 1662 1105 403 1353 922 255 1399 613 1343 410 120 1908 1284 1801 468 1 66 10 1233 433 151 1728 ...
output:
1 1000 2000 2 293 1537 2 1956 1638 6 411 778 1 82 549 1 1312 528 4 776 700 1 115 17 9 1021 283 9 411 1800 1 236 1082 1 849 1864 1 627 1550 1 679 605 6 811 510 2 1734 493 9 1032 1455 4 484 204 1 464 607 3 899 541 1 126 1350 1 256 681 3 391 617 1 265 627 2 510 763 1 198 831 1 507 263 2 1047 1678 1 382...
result:
wrong answer 15th lines differ - expected: '9 1531 716', found: '6 811 510'