#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
typedef int64_t ll;
typedef long double ld;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int,int>
#define F(n) Fi(i,n)
#define Fi(i,n) Fl(i,0,n)
#define Fl(i,l,n) for(int i=l;i<n;i++)
#define RF(n) RFi(i,n)
#define RFi(i,n) RFl(i,0,n)
#define RFl(i,l,n) for(int i=n-1;i>=l;i--)
#define all(v) begin(v),end(v)
#define siz(v) (ll(v.size()))
#define get_pos(v,x) (lower_bound(all(v),x)-begin(v))
#define sort_uni(v) sort(begin(v),end(v)),v.erase(unique(begin(v),end(v)),end(v))
#define mem(v,x) memset(v,x,sizeof v)
#define ff first
#define ss second
#define mid ((l+r)>>1)
#define RAN(a,b) uniform_int_distribution<int> (a, b)(rng)
#define debug(x) (cerr << (#x) << " = " << x << "\n")
#define cmax(a,b) (a = max(a,b))
#define cmin(a,b) (a = min(a,b))
template <typename T> using max_heap = __gnu_pbds::priority_queue<T,less<T> >;
template <typename T> using min_heap = __gnu_pbds::priority_queue<T,greater<T> >;
template <typename T> using rbt = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
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 R,C,Q;
int st, ed;
void PP(){
if(st == ed) printf("%d 1\n", R-1);
else printf("0 0\n");
}
void RR(){
if(st == ed) printf("1 1");
else printf("2 2");
}
void QQ(){
if(st == ed) printf("1 1");
int ans = 0;
ans ++; // first horizontal
ans += 2; // first vertical
ans ++; // first diagonal, then vertical;
if((st+1+ed+R) % 2 == 0){ // (st, 1) & (ed, R)
// up-right
int k = (R-1+ed-st)>>1;
int l = (R-1+st-ed)>>1;
if(st+k <= C) ans++;
// up-left
k = (R-1-ed+st)>>1;
l = (R-1-st+ed)>>1;
if(st-k > 0) ans++;
}
printf("2 %d", ans);
}
void KK(){
printf("-1 -1\n");
}
void BB(){
printf("-2 -2\n");
}
signed main(){
cin >> R >> C >> Q;
while(Q--){
char c;
cin >> c;
cin >> st >> ed;
switch(c){
case 'P':
PP();
break;
case 'Q':
QQ();
break;
case 'R':
RR();
break;
case 'B':
BB();
break;
case 'K':
KK();
break;
default:
assert(0);
break;
}
}
return 0;
}
Compilation message
chessrush.cpp: In function 'void QQ()':
chessrush.cpp:96:9: warning: variable 'l' set but not used [-Wunused-but-set-variable]
96 | int l = (R-1+st-ed)>>1;
| ^
/usr/bin/ld: /tmp/ccjNNDQ3.o: in function `Add(int, int)':
arithmetics.cpp:(.text+0x0): multiple definition of `Add(int, int)'; /tmp/ccJeJU80.o:chessrush.cpp:(.text+0x0): first defined here
/usr/bin/ld: /tmp/ccjNNDQ3.o: in function `Sub(int, int)':
arithmetics.cpp:(.text+0x80): multiple definition of `Sub(int, int)'; /tmp/ccJeJU80.o:chessrush.cpp:(.text+0x80): first defined here
/usr/bin/ld: /tmp/ccjNNDQ3.o: in function `Mul(int, int)':
arithmetics.cpp:(.text+0x100): multiple definition of `Mul(int, int)'; /tmp/ccJeJU80.o:chessrush.cpp:(.text+0x100): first defined here
/usr/bin/ld: /tmp/ccjNNDQ3.o: in function `modpow(int, int, int)':
arithmetics.cpp:(.text+0x190): multiple definition of `modpow(int, int, int)'; /tmp/ccJeJU80.o:chessrush.cpp:(.text+0x190): first defined here
/usr/bin/ld: /tmp/ccjNNDQ3.o: in function `modinv(int, int)':
arithmetics.cpp:(.text+0x1f0): multiple definition of `modinv(int, int)'; /tmp/ccJeJU80.o:chessrush.cpp:(.text+0x1f0): first defined here
/usr/bin/ld: /tmp/ccjNNDQ3.o: in function `Div(int, int)':
arithmetics.cpp:(.text+0x290): multiple definition of `Div(int, int)'; /tmp/ccJeJU80.o:chessrush.cpp:(.text+0x290): first defined here
collect2: error: ld returned 1 exit status