Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int n,m,a,b;
- char W;
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- cin>>n>>m;
- for(int k=0;k<m;k++){
- cin>>W;
- if(W=='P'){
- cin>>a>>b;
- a+=n-1;
- b+=n-1;
- while(a!=b){
- a/=2;
- b/=2;
- }
- cout<<a<<"\n";
- }
- else{
- cin>>a;
- b=a;
- while(a<n&&b<n){
- a=a*2;
- b=(b*2)+1;
- }
- cout<<a-(n-1)<<" "<<b-(n-1)<<"\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement