QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#303606 | #6305. Chinese Checker | ucup-team052# | WA | 3ms | 3428kb | C++14 | 3.4kb | 2024-01-12 20:06:45 | 2024-01-12 20:06:46 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
using namespace std;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;
template <typename _T>
inline void read(_T &f) {
f = 0; _T fu = 1; char c = getchar();
while (c < '0' || c > '9') { if (c == '-') { fu = -1; } c = getchar(); }
while (c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
f *= fu;
}
template <typename T>
void print(T x) {
if (x < 0) putchar('-'), x = -x;
if (x < 10) putchar(x + 48);
else print(x / 10), putchar(x % 10 + 48);
}
template <typename T>
void print(T x, char t) {
print(x); putchar(t);
}
const int N = 18;
const int dx[6] = {0, 0, 1, 1, -1, -1};
const int dy[6] = {1, -1, 0, 1, 0, -1};
queue <pii> q;
int a[N][N], b[N][N], x[N * N], y[N * N];
int T, n;
bool in(int x, int y) {
if (x < 1 || x > 17) return 0;
if (x >= 1 && x <= 4) return y >= 1 && y <= x;
if (x >= 5 && x <= 9) return y >= x - 8 && y <= 9;
if (x >= 10 && x <= 13) return y >= 1 && y <= x;
return y >= x - 8 && y <= 8;
}
int chk(int x, int y) {
if (x < 1 || x > 17) return 0;
if (x >= 1 && x <= 4) return y >= 1 && y <= x && a[x][y + 4] == 0;
if (x >= 5 && x <= 9) return y >= x - 8 && y <= 9 && a[x][y + 4] == 0;
if (x >= 10 && x <= 13) return y >= 1 && y <= x && a[x][y + 4] == 0;
return y >= x - 8 && y <= 8 && a[x][y + 4] == 0;
}
int main() {
read(T);
while (T--) {
memset(a, 0, sizeof(a));
read(n);
for (int i = 1; i <= n; i++) {
read(x[i]); read(y[i]);
if (x[i] >= 5 && x[i] <= 8) y[i] -= (9 - x[i]);
if (x[i] >= 14) y[i] += x[i] - 9;
a[x[i]][y[i] + 4] = 1;
}
int ans = 0;
for (int i = 1; i <= n; i++) {
memset(b, 0, sizeof(b));
a[x[i]][y[i] + 4] = 0;
q.push(make_pair(x[i], y[i])); b[x[i]][y[i] + 4] = 1;
--ans;
while (!q.empty()) {
pii t = q.front(); q.pop(); ++ans;
for (int d = 0; d < 6; d++) {
int pos = 0;
for (int i = 1; ; i++) {
if (!in(t.first + dx[d] * i * 2, t.second + dy[d] * i * 2)) break;
if (a[t.first + dx[d] * i][t.second + dy[d] * i + 4]) {
pos = i;
break;
}
}
if (pos && !b[t.first + dx[d] * pos * 2][t.second + dy[d] * pos * 2 + 4]) {
int ok = 1;
for (int i = 0; i < pos; i++) {
if (a[t.first + dx[d] * (pos * 2 - i)][t.second + dy[d] * (pos * 2 - i) + 4]) {
ok = 0;
break;
}
}
if (ok) {
b[t.first + dx[d] * pos * 2][t.second + dy[d] * pos * 2 + 4] = 1;
q.push(make_pair(t.first + dx[d] * pos * 2, t.second + dy[d] * pos * 2));
}
}
}
}
a[x[i]][y[i] + 4] = 1;
}
print(ans, '\n');
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3428kb
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: 3420kb
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:
179 345 192 490 364 214 149 39 318 87 1 126 103 62 25 137 382 294 10 214 90 174 240 16 97 227 290 438 166 80 200 266 25 6 99 172 387 282 51 158 263 47 10 138 77 179 30 145 328 115 170 279 0 105 89 54 22 5 60 149 163 26 397 161 206 4 49 0 251 105 99 384 0 347 75 105 67 353 62 27 460 349 6 187 87 2 14...
result:
wrong answer 1st numbers differ - expected: '190', found: '179'