QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#288083 | #6305. Chinese Checker | Jacka1# | WA | 27ms | 3480kb | C++14 | 3.6kb | 2023-12-21 19:31:21 | 2023-12-21 19:31:22 |
Judging History
answer
int main() {}
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const int solve = []() {
const vector<pair<int, int>> dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}, {1, 1}, {-1, -1}};
vector<vector<pair<int, int>>> real(18, vector<pair<int, int>>(18));
vector<vector<int>> ok(18, vector<int>(18));
for (int i = 1; i <= 13; i++) {
if (i > 4 and i <= 8) continue;
for (int j = 1; j <= i; j++) {
real[i][j] = {i, j + 4};
ok[i][j + 4] = 1;
}
}
for (int i = 1; i <= 13; i++) {
if (i > 4 and i <= 9) continue;
for (int j = i; j <= 13; j++) {
real[i + 4][j - i + 1] = {i + 4, j};
ok[i + 4][j] = 1;
}
}
// for (int i = 1; i <= 17; i++) {
// for (int j = 1; j <= 17; j++) {
// cout << ok[i][j] << " \n"[j == 17];
// }
// }
int T;
cin >> T;
while (T--) {
int n;
cin >> n;
vector<vector<int>> vis(18, vector<int>(18));
vector<vector<int>> grid(18, vector<int>(18));
while (n--) {
int x, y;
cin >> x >> y;
auto [rx, ry] = real[x][y];
grid[rx][ry] = 1;
}
int ans = 0;
auto outside = [&](int x, int y) {
if (x < 1 or x > 17 or y < 1 or y > 17) return true;
return not ok[x][y];
};
auto valid = [&](int x, int y) {
return not outside(x, y) and not grid[x][y] and not vis[x][y];
};
for (int i = 1; i <= 17; i++) {
for (int j = 1; j <= 17; j++) {
if (grid[i][j]) {
set<pair<int, int>> S;
auto dfs = [&](auto self, int x, int y) -> void {
vis[x][y] = true;
S.emplace(x, y);
for (auto& [dx, dy] : dir) {
int tx = x, ty = y;
int mx = -1, my = -1;
while (true) {
tx += dx, ty += dy;
if (outside(tx, ty)) {
break;
}
if (grid[tx][ty]) {
mx = tx;
my = ty;
break;
}
}
if (mx == -1) {
continue;
} else {
int gx = 2 * mx - x;
int gy = 2 * my - y;
if (valid(gx, gy)) {
grid[x][y] = 0;
grid[gx][gy] = 1;
self(self, gx, gy);
grid[x][y] = 1;
grid[gx][gy] = 0;
}
}
}
vis[x][y] = false;
};
dfs(dfs, i, j);
ans += S.size() - 1;
// cout << i << ' ' << j << ":\n";
// for (auto& [x, y] : S) {
// cout << x << ' ' << y << endl;
// }
}
}
}
cout << ans << '\n';
}
return 0;
}();
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3480kb
input:
5 1 1 1 2 1 1 2 1 2 9 4 9 6 10 1 1 2 1 2 2 3 1 3 2 3 3 4 1 4 2 4 3 4 4 10 1 1 2 1 2 2 5 7 3 2 3 3 4 1 4 2 4 3 4 4
output:
0 1 2 6 13
result:
ok 5 number(s): "0 1 2 6 13"
Test #2:
score: -100
Wrong Answer
time: 27ms
memory: 3440kb
input:
100 81 1 1 16 1 11 4 13 8 12 3 12 12 11 1 4 2 9 5 8 10 5 5 9 7 3 2 14 1 7 11 13 7 10 2 8 3 9 8 10 6 12 10 6 7 11 2 7 3 13 12 8 6 17 1 10 5 5 12 13 9 13 1 9 4 5 10 11 8 13 4 5 4 9 1 7 8 5 6 13 13 5 1 9 3 8 8 8 5 13 2 13 5 11 3 9 2 6 4 3 3 8 2 13 11 8 7 5 7 6 10 11 9 10 3 11 10 6 3 7 1 4 4 15 2 7 2 3 ...
output:
361 643 344 720 620 408 209 45 508 93 1 371 117 131 25 202 606 482 10 273 187 243 647 16 112 465 494 674 313 93 308 471 25 10 153 306 609 399 53 322 576 50 10 333 80 292 33 245 576 137 312 492 0 120 130 90 22 5 99 229 218 26 622 232 323 4 68 0 415 144 148 517 0 564 100 112 92 457 90 34 778 645 7 372...
result:
wrong answer 1st numbers differ - expected: '190', found: '361'