#include <iostream>
using namespace std;
int main(){
cin.tie(0)->sync_with_stdio(0);
int n, m, q; cin >> n >> m >> q;
while (q--){
char t; cin >> t;
int a, b; cin >> a >> b;
a--, b--;
if (t == 'P'){
if (a == b){
cout << 1 << ' ' << 1 << '\n';
}else{
cout << 0 << ' ' << 0 << '\n';
}
}else if (t == 'R'){
if (a == b){
cout << 1 << ' ' << 1 << '\n';
}else{
cout << 2 << ' ' << 2 << '\n';
}
}else if (t == 'Q'){
if (a == b || n - 1 == abs(a - b)){
cout << 1 << ' ' << 1 << '\n';
}else{
int ans = 4;
if (b + n - 1 > a && b + n - 1 < m) ans++;
// cout << ans << endl;
if (b - (n - 1) < a && b - (n - 1) >= 0) ans++;
// cout << ans << endl;
if (a + n - 1 > b && a + n - 1 < m) ans++;
// cout << ans << endl;
if (a - (n - 1) < b && a - (n - 1) >= 0) ans++;
// cout << ans << endl;
for (int i = min(a, b) - 1; i >= 0; i--){
if (a - i + b - i == n - 1) ans++;
}
for (int i = max(a, b) + 1; i < m; i++){
if (i - a + i - b == n - 1) ans++;
}
cout << 2 << ' ' << ans << '\n';
}
}else if (t == 'B'){
cout << -1 << '\n';
}else if (t == 'K'){
cout << -1 << '\n';
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 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 |
0 ms |
316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
316 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 |
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 |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |