#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
const int NMAX = 100001;
const int VMAX = 101;
const int INF = 2e9;
const int MOD = 1000000007;
const int BLOCK = 447;
const int base = 117;
const int nr_of_bits = 24;
const int inv2 = 500000004;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int R, C, q;
cin >> R >> C >> q;
while(q--) {
char T;
cin >> T;
int c1, cr;
cin >> c1 >> cr;
if(T =='P') {
if(c1 == cr){
cout << R - 1 << " " << 1 << "\n";
}else{
cout << 0 << " " << 0 << "\n";
}
}else if(T == 'R'){
if(c1 == cr){
cout << 1 << " " << 1 << "\n";
}else{
cout << 2 << " " << 2 << "\n";
}
}else if(T == 'Q'){
pii start = {1, c1};
pii sfarsit = {R, cr};
if(start.second == sfarsit.second || sfarsit.first + sfarsit.second == start.first + start.second || sfarsit.first - sfarsit.second == start.first - start.second){
cout << 1 << " " << 1 << "\n";
}else{
int cnt = 2;
for(int i = start.first, j = start.second; i > 0 && j > 0; i--, j--){
if(i + j == sfarsit.first + sfarsit.second || i - j == sfarsit.first - sfarsit.second || i == sfarsit.first || j == sfarsit.second){
cnt++;
}
}
for(int i = start.first, j = start.second; i <= R && j > 0; i++, j--){
if(i + j == sfarsit.first + sfarsit.second || i - j == sfarsit.first - sfarsit.second || i == sfarsit.first || j == sfarsit.second)
cnt++;
}
for(int i = start.first, j = start.second; i > 0 && j <= C; i--, j++){
if(i + j == sfarsit.first + sfarsit.second || i - j == sfarsit.first - sfarsit.second || i == sfarsit.first || j == sfarsit.second)
cnt++;
}
for(int i = start.first, j = start.second; i <= R && j <= C; i++, j++){
if(i + j == sfarsit.first + sfarsit.second || i - j == sfarsit.first - sfarsit.second || i == sfarsit.first || j == sfarsit.second){
cnt++;
}
}
swap(start, sfarsit);
for(int i = start.first, j = start.second; i > 0 && j > 0; i--, j--){
if(i == sfarsit.first || j == sfarsit.second){
cnt++;
}
}
for(int i = start.first, j = start.second; i <= R && j > 0; i++, j--){
if(i == sfarsit.first || j == sfarsit.second)
cnt++;
}
for(int i = start.first, j = start.second; i > 0 && j <= C; i--, j++){
if(i == sfarsit.first || j == sfarsit.second)
cnt++;
}
for(int i = start.first, j = start.second; i <= R && j <= C; i++, j++){
if(i == sfarsit.first || j == sfarsit.second){
cnt++;
}
}
cout << 2 << " " << cnt << "\n";
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
320 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
320 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |