#include "arithmetics.h"
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k, l) for(int i = (j); i < (k); i += (l))
#define FORD(i,j , k, l) for(int i = (j); i >= (k); i -= (l))
#define REP(i, n) FOR(i, 0, n, 1)
#define REPD(i, n) FORD(i, n, 0, 1)
typedef long long ll;
int main(){
int r, c, q;
cin >> r >> c >> q;
auto solve_pawn = [&](int c1, int cr)->array<int,2>{
if(c1 != cr)
return {0, 0};
else{
return {r - 1, 1};
}
};
auto solve_queen = [&](int c1, int cr)->array<int,2>{
if(c1 == cr){
return {1, 1};
}
else if(abs(c1 - cr) == r - 1){
return {1, 1};
}
else{
array<int, 2> res = {2, 4};
int f = r - 1 + cr - c1; int xf = f / 2;
if(f % 2 == 0 && c1 + xf <= c && r - 1 - xf >= 0)
res[1]++;
int s = r - 1 + c1 - cr; int xs = s / 2;
if(s % 2 == 0 && c1 - xs >= 1 && r - 1 - xs >= 0)
res[1]++;
/*
if(c1 < cr && (r - tm) % 2 == 0 && cr + (r - tm) / 2 <= c)
res[1]++;
if(c1 > cr && (r - tm) % 2 == 0 && cr - (r - tm) / 2 >= 1)
res[1]++;
*/
return res;
}
};
auto solve_rook = [&](int c1, int cr)->array<int,2>{
if(c1 == cr){
return {1, 1};
}
else{
return {2, 2};
}
};
REP(i, q){
char t;
int c1, cr;
cin >> t >> c1 >> cr;
array<int, 2> res;
if(t == 'P')
res = solve_pawn(c1, cr);
else if(t == 'Q')
res = solve_queen(c1, cr);
else if(t == 'R')
res = solve_rook(c1, cr);
cout << res[0] << " " << res[1] << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |