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 "bits/stdc++.h"
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int r, c, q;
cin >> r >> c >> q;
while (q--) {
char p;
int c1, c2;
cin >> p >> c1 >> c2;
if (p == 'P') {
if (c1 == c2) {
cout << 1 << ' ' << 1 << '\n';
} else {
cout << 0 << ' ' << 0 << '\n';
}
}
else if (p == 'R') {
if (c1 == c2) {
cout << 1 << ' ' << 1 << '\n';
} else {
cout << 2 << ' ' << 2 << '\n';
}
}
else if (p == 'Q') {
if (r - 1 == abs(c2 - c1)) {//diagonal
cout << 1 << ' ' << 1 << '\n';
}
else if (c1 == c2) {
cout << 1 << ' ' << 1 << '\n';
} else {
cout << 2 << ' ' << 4 + (((r - 1) + abs(c2 - c1)) % 2 == 0) << '\n';
}
} else {
cout << 0 << ' ' << 0 << '\n';
}
}
return 0;
}
# | 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... |