QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#44443 | #4638. Xiangqi | Qingyu | WA | 100ms | 3764kb | C++20 | 1.4kb | 2022-08-17 14:32:21 | 2022-08-17 14:49:23 |
Judging History
answer
#include <bits/stdc++.h>
typedef long long ll;
ll go(ll x, ll y) {
if (!y && (x == 1 || x == -1))
return 3;
if (!x && (y == 1 || y == -1))
return 3;
if ((x == 2 || x == -2) && (y == 2 || y == -2))
return 4;
ll ans = std::max(std::max((x + 1) / 2, (y + 1) / 2), (x + y + 2) / 3);
if (ans % 2 != (x ^ y) % 2)
++ans;
return ans;
}
ll solve(ll xh, ll yh, ll xc, ll yc) {
if (xh < 0) xh = -xh, xc = -xc;
if (yh < 0) yh = -yh, yc = -yc;
ll ans = go(xh, yh);
for (int _ = 0; _ < 2; _++) {
if (xh == yh * 2 && xc > 0 && xc < xh && yc == (xc + 1) / 2) {
ans += 1;
}
std::swap(xh, yh);
std::swap(xc, yc);
}
for (int _ = 0; _ < 2; _++) {
ll z = (xh + 1) / 2;
ll dy = xh / 2;
if (xh & 1) dy += 2;
if (dy < yh) {
ll ny = yh - dy;
if (xc == 0 && yc > ny) {
ans = std::min(ans, z + 1);
}
else if (yc > ny) {
ans = std::min(ans, z + 2);
}
else if (xc == 0 && yc > 0 && xh != 0) {
ans = std::min(ans, z + 2);
}
else if (xc != 0) {
ans = std::min(ans, z + 3);
}
else {
ans = std::min(ans, z + 4);
}
}
std::swap(xh, yh);
std::swap(xc, yc);
}
return ans;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
int T;
std::cin >> T;
while (T--) {
int x1, y1, x2, y2;
std::cin >> x1 >> y1 >> x2 >> y2;
std::cout << solve(x1, y1, x2, y2) << '\n';
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3556kb
input:
5 -2 1 5 5 5 0 6 0 2 1 1 1 100 2 -1 0 4 2 1 1
output:
1 1 2 5 3
result:
ok 5 lines
Test #2:
score: -100
Wrong Answer
time: 100ms
memory: 3764kb
input:
388752 -12 -12 -12 -11 -12 -12 -12 -10 -12 -12 -12 -9 -12 -12 -12 -8 -12 -12 -12 -7 -12 -12 -12 -6 -12 -12 -12 -5 -12 -12 -12 -4 -12 -12 -12 -3 -12 -12 -12 -2 -12 -12 -12 -1 -12 -12 -12 0 -12 -12 -12 1 -12 -12 -12 2 -12 -12 -12 3 -12 -12 -12 4 -12 -12 -12 5 -12 -12 -12 6 -12 -12 -12 7 -12 -12 -12 8 ...
output:
8 8 8 8 8 8 8 8 8 8 8 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 7 8 8 8 8 8 8 8 8 8 8 8 8 8 ...
result:
wrong answer 286th lines differ - expected: '9', found: '8'