#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 comb(int n, int k) {
if(k < n - k) {
k = n - k;
}
ll prod = 1, prod2 = 1;
for(int i = k + 1; i <= n; i++) {
prod *= i;
prod %= MOD;
prod2 *= (i - k);
prod2 %= MOD;
}
return Div(prod, prod2);
}
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;
}
Compilation message
chessrush.cpp: In function 'int comb(int, int)':
chessrush.cpp:29:12: error: 'Div' was not declared in this scope; did you mean 'div'?
29 | return Div(prod, prod2);
| ^~~
| div