Advertisement
Guest User

Nikic gej

a guest
Feb 22nd, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int n, x, y, d;
  4. string s;
  5. int main (){
  6. cin >> n >> x >> y >> s;
  7. for (int i=0; i<s.size(); i++){
  8. if(s[i] == 'L') d--;
  9. if(s[i] == 'D') d++;
  10. if(abs(d) == 4) d=0;
  11. if(s[i] == 'N'){
  12. if (d==0) x++;
  13. if (d==1) y--;
  14. if (d==2) x--;
  15. if (d==3) y++;
  16. if (d==-1) y++;
  17. if (d==-2) x--;
  18. if (d==-3) y--;
  19. }
  20. }
  21. cout << x << " " << y << endl;
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement