This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "arithmetics.h"
#include <bits/stdc++.h>
using i64 = long long;
i64 R;
int C, Q;
int main() {
std::cin >> R >> C >> Q;
auto solve1 = [&](int a, int b, i64 r = R, i64 c = C) -> std::pair<i64, i64> {
if (a == b) {
return {r - 1, 1};
} else {
return {0, 0};
}
};
auto solve2 = [&](int a, int b, i64 r = R, i64 c = C) -> std::pair<i64, i64> {
if (a == b) {
return {1, 1};
} else {
return {2, 2};
}
};
auto solve3 = [&](int a, int b) -> std::pair<i64, i64> {
auto judge1Turn = [&](int a, int b, int r = R, int c = C) {
if (std::max(a - b, (int)r - 1) <= 1) {
return true;
}
if (a == b) {
return true;
}
if (std::abs(a - b) == std::abs(r - 1)) {
return true;
}
return false;
};
if (judge1Turn(a, b)) {
return {1, 1};
}
int v = 4;
const int w = std::abs(a - b);
if (w != 1) {
if (b - 1 == a) ++v;
if (b + 1 == a) ++v;
if (a - 1 == b) ++v;
if (a + 1 == b) ++v;
}
if (R - 1 - w != 1) {
if (judge1Turn(a, b, R - 1, C)) v += 2;
}
// r -> r
int x = 1 + a;
int y = R + b;
if (x % 2 == y % 2) {
if (a - 1 + b - 1 >= R - 1) ++v;
if (R - a + R - b >= R - 1) ++v;
}
return {2, v};
};
auto solve4 = [&](int a, int b) -> std::pair<i64, i64> {
return {-1, -1};
int x = 1 + a;
int y = R + b;
if (x % 2 == y % 2) {
}
};
auto solve5 = [&](int a, int b) -> std::pair<i64, i64> {
return {-1, -1};
};
while (Q--) {
char T;
int a, b;
std::cin >> T >> a >> b;
std::pair<i64, i64> answer = {-1, -1};
if (T == 'P') answer = solve1(a, b);
if (T == 'R') answer = solve2(a, b);
if (T == 'Q') answer = solve3(a, b);
if (T == 'B') answer = solve4(a, b);
if (T == 'K') answer = solve5(a, b);
std::cout << answer.first << ' ' << answer.second << std::endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |