Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int n, x, y, d;
- string s;
- int main (){
- cin >> n >> x >> y >> s;
- for (int i=0; i<s.size(); i++){
- if(s[i] == 'L') d--;
- if(s[i] == 'D') d++;
- if(abs(d) == 4) d=0;
- if(s[i] == 'N'){
- if (d==0) x++;
- if (d==1) y--;
- if (d==2) x--;
- if (d==3) y++;
- if (d==-1) y++;
- if (d==-2) x--;
- if (d==-3) y--;
- }
- }
- cout << x << " " << y << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement