QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#140886 | #6305. Chinese Checker | supepapupu | WA | 14ms | 3508kb | C++17 | 2.3kb | 2023-08-16 22:19:40 | 2023-08-16 22:19:44 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
#define el '\n'
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 3e5 + 10, INF = 0x3f3f3f3f, mod = 998244353;
inline int read() {
int f = 1, k = 0;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
k = k * 10 + c - '0';
c = getchar();
}
return f * k;
}
int n;
ll ans;
vector<pii> q;
set<pii> S;
int L[] = {0, 5, 5, 5, 5, 1, 2, 3, 4, 5, 5, 5, 5, 5, 10, 11, 12, 13};
int R[] = {0, 5, 6, 7, 8, 13, 13, 13, 13, 13, 14, 15, 16, 17, 13, 13, 13, 13};
void bfs(int u) {
set<pii> st;
queue<pii> Q;
st.insert(q[u]);
Q.push(q[u]);
while (Q.size()) {
auto[x, y] = Q.front();
Q.pop();
auto get = [&](int p)->pii {
auto[a, b] = q[p];
int dx = a - x, dy = b - y;
pii fail = {-1, -1};
if (dx && dy && dx != dy) return fail;
pii res = {a + dx, b + dy};
if (res.x <= 0 || res.x > 17) return fail;
if (res.y < L[res.x] || res.y > R[res.x]) return fail;
if (S.count(res)) return fail;
if (dx) dx = dx > 0 ? 1 : -1;
if (dy) dy = dy > 0 ? 1 : -1;
for (int i = x + dx, j = y + dy; i != res.x || j != res.y; i += dx, j += dy) {
if (i == a && j == b) continue;
if (S.count({i, j})) return fail;
}
return res;
};
for (int i = 0; i < n; ++i) {
if (i == u) continue;
auto[a, b] = get(i);
if (~a) {
if (!st.count({a, b})) {
st.insert({a, b});
Q.push({a, b});
}
}
}
}
ans += st.size() - 1;
}
void solve() {
n = read();
q.clear();
S.clear();
for (int i = 0; i < n; ++i) {
int x = read(), y = read();
y += L[x] - 1;
q.emplace_back(x, y);
S.insert({x, y});
}
ans = 0;
for (int i = 0; i < n; ++i) {
bfs(i);
}
cout << ans << el;
}
int main() {
int tcase;
cin >> tcase;
while (tcase--) solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3476kb
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: 14ms
memory: 3508kb
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:
190 368 210 491 370 224 151 39 328 87 1 131 103 65 25 137 391 294 10 214 82 188 261 16 102 236 300 439 172 84 211 281 25 7 104 181 429 282 51 163 265 47 10 149 79 181 30 145 328 122 199 289 0 105 114 53 22 5 59 159 167 26 446 163 209 4 52 0 251 109 100 401 0 347 75 105 73 353 65 28 472 352 6 190 90 ...
result:
wrong answer 2nd numbers differ - expected: '376', found: '368'