QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#95113 | #6305. Chinese Checker | kuroni | WA | 3ms | 3488kb | C++20 | 2.6kb | 2023-04-09 07:03:50 | 2023-04-09 07:03:51 |
Judging History
answer
#include <bits/stdc++.h>
#define vis(x, y) vis[x][y - BOUNDS[x][0]]
#define g(x, y) g[x][y - BOUNDS[x][0]]
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
const int N = 17;
const array LEN{1, 2, 3, 4, 13, 12, 11, 10, 9, 10, 11, 12, 13, 4, 3, 2, 1};
const array<array<int, 2>, N> BOUNDS{{{0, 1}, {0, 2}, {0, 3}, {0, 4}, {-4, 9}, {-3, 9}, {-2, 9}, {-1, 9}, {0, 9}, {0, 10}, {0, 11}, {0, 12}, {0, 13}, {6, 10}, {7, 10}, {8, 10}, {9, 10}}};
const array<array<int, 2>, 6> DELTAS{{{-1, 0}, {0, 1}, {1, 1}, {1, 0}, {0, -1}, {-1, -1}}};
int t; cin >> t;
while (t--) {
int n; cin >> n;
array<bitset<N>, N> g;
for (int i = 0; i < n; ++i) {
int x, y; cin >> x >> y;
--x, --y;
y += BOUNDS[x][0];
g(x, y) = 1;
}
auto in = [&](int x, int y) {
return 0 <= x && x < N && BOUNDS[x][0] <= y && y < BOUNDS[x][1];
};
auto bfs = [&](int sx, int sy) {
array<bitset<N>, N> vis;
queue<array<int, 2>> q;
int cnt = 0;
vis(sx, sy) = 1;
q.push({sx, sy});
// cerr << sx << ' ' << sy << '\n';
while (!empty(q)) {
auto [x, y] = q.front(); q.pop();
++cnt;
// cerr << x << ' ' << y << '\n';
for (auto& [dx, dy] : DELTAS) {
int pivot = 0, bx = x, by = y;
while (in(bx, by) && !g(bx, by)) {
++pivot, bx += dx, by += dy;
}
if (!in(bx, by)) {
continue;
}
bool ok = true;
int nx = bx, ny = by;
for (int i = 0; i < pivot; ++i) {
nx += dx, ny += dy;
ok = ok && in(nx, ny) && !g(nx, ny);
}
if (ok && !vis(nx, ny)) {
vis(nx, ny) = 1;
q.push({nx, ny});
}
}
}
return cnt;
};
int ans = 0;
for (int x = 0; x < N; ++x) {
for (int y = BOUNDS[x][0]; y < BOUNDS[x][1]; ++y) {
if (g(x, y)) {
g(x, y) = 0;
ans += bfs(x, y) - 1;
g(x, y) = 1;
}
}
}
cout << ans << '\n';
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3456kb
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: 3ms
memory: 3488kb
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:
192 357 187 492 406 215 147 40 291 88 1 135 100 58 25 137 364 311 10 222 90 196 335 16 101 240 283 414 177 86 218 265 25 7 115 189 383 282 54 170 283 46 10 140 81 167 30 147 308 121 183 294 0 105 85 53 21 5 72 147 174 26 411 164 217 4 52 0 258 105 102 455 0 343 72 103 51 317 61 29 490 349 6 193 92 2...
result:
wrong answer 1st numbers differ - expected: '190', found: '192'