1 solutions
-
0
C++ :
#include<bits/stdc++.h> using namespace std; typedef long long LL; const LL imx=1e12; LL n,id,cnt; char ch; int main() { cin>>n>>id; while(n--) { cin>>ch; if(ch=='U') { if(cnt!=0) { cnt--; continue; } if(id!=1) id=id/2; } else if(ch=='L') { if(id*2>imx) cnt++; else id=id*2; } else { if(id*2>imx) cnt++; else id=id*2+1; } } cout<<id<<endl; return 0; } /* in: 3 2 URR out: 7 */
- 1
Information
- ID
- 111
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By