This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast","O3","unroll-loops")
#pragma GCC target("avx2")
#include<bits/stdc++.h>
using namespace std;
#define double long double
#define int long long
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define rz resize
#define pb emplace_back
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define ACorz ios_base::sync_with_stdio(false);cin.tie(0);
#define endl '\n'
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int INF=1e9,INF2=2e9;
const int mod=1e9+7;
const int mod1=998244353;
const int N=1000005;
const int K=45000;
const int M=5000;
int n,m;
void P(int a,int b){
if(a==b){
cout<<n-1<<' '<<1<<endl;
}
else{
cout<<0<<' '<<0<<endl;
}
}
void R(int a,int b){
if(a==b){
cout<<1<<' '<<1<<endl;
}
else{
cout<<2<<' '<<2<<endl;
}
}
void Q(int a,int b){
if(a==b||a+n==b+1||a+1==b+n){
cout<<1<<' '<<1<<endl;
return;
}
int ans=0;
if(b<a){
swap(a,b);
}
// R RU U LU L
//R
ans++;
if(b+n-1<=m)ans++;
if(b-n+1>a)ans++;
//RU
if(a+n-1<=m&&a+n-1>b)ans++;
if(a+n-1>b)ans++;
if(a+n-1<b)ans++;
if((b-a+n-1)%2==0){
int pos=(b-a+n-1)/2;
if(pos>b&&pos<=m)ans++;
}
//U
if(b-n+1<a)ans++;
ans++;
//LU
if((a-n+1)>=1)ans++;
if((a-b+n-1)%2==0){
int pos=(a-b+n-1)/2;
if(pos>=1&&pos<a)ans++;
}
//L
if((b-n+1)>=1)ans++;
cout<<2<<' '<<ans<<endl;
}
signed main(){
ACorz;
int q;
cin>>n>>m>>q;
for(int i=0;i<q;i++){
char c;int a,b;cin>>c>>a>>b;
if(c=='R')R(a,b);
if(c=='Q')Q(a,b);
if(c=='P')P(a,b);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |