# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1159365 | shn | Chess Rush (CEOI20_chessrush) | C++20 | 0 ms | 0 KiB |
// #include "arithmetics.h"
#include <bits/stdc++.h>
using namespace std;
constexpr int P = 1e9+7;
int Add(int a, int b) {
int ret = a%P;
ret = (ret<0 ? P+ret : ret) + (b%P);
return (ret>=0 ? ret%P : ret+P);
}
//
// int Sub(int a, int b) {
// int ret = a%P;
// ret = (ret<0 ? P+ret : ret) - (b%P);
// return (ret>=0 ? ret%P : ret+P);
// }
//
// int Mul(int a, int b) {
// int ret = (1ll*(a%P) * (b%P)) % P;
// return (ret<0 ? P+ret : ret);
// }
// int modpow(int base, int exp, int modulus=P) {
// base %= modulus;
// int result = 1;
// while (exp > 0) {
// if (exp & 1) result = (1ll*result * base) % modulus;
// base = (1ll*base * base) % modulus;
// exp >>= 1;
// }
// return result;
// }
// int modinv(int a, int modulus=P) {
// return modpow(a,modulus-2);
// }
//
// int Div(int a, int b) {
// int ret = b%P;
// ret = (1ll*(a%P) * modinv(ret<0 ? P+ret : ret)) % P;
// return (ret<0 ? P+ret : ret);
// }
int main(){
int r , c , q;
cin >> c >> r >> q;
while(q--){
char tt;
cin >> tt;
if(tt == 'P'){
int x , y;
cin >> x >> y;
if(x != y){
cout << "0 0" << '\n';
continue;
}
cout << "1 1\n";
}
else if(tt == 'R'){
int x , y;
cin >> x >> y;
if(x == y){
cout << "1 1\n";
continue;
}
cout << "2 2\n";
}
else if(tt == 'Q'){
int x , y;
cin >> x >> y;
if(x == y || abs(x - y) == abs(1 - r)){
cout << "1 1\n";
continue;
}
cout << 2 << ' ';
if((1 + x) % 2 == (r + y) % 2){
cout << 6 << '\n';
}
else{
cout << 5 << '\n';
}
// int ans = 2;
// for(int j = 1; j <= c; j++){
// if(j == x){
// continue;
// }
// int x2 = 1 + abs(j - x);
// if(abs(x2 - r) == abs(j - y)) ans = Add(ans , 1);
// if(x2 == r) ans = Add(ans , 1);
// if(j == y) ans = Add(ans , 1);
// x2 = 1;
// if(abs(x2 - r) == abs(j - y)) ans = Add(ans , 1);
// if(j == y) ans = Add(ans , 1);
// }
// cout << 2 << ' ' << ans << '\n';
}
else{
cout << "0 0\n";
continue;
}
}
}