Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* http://www.z-trening.com/tasks.php?show_task=5000000710 */
- #include <iostream>
- using namespace std;
- int main()
- {
- string s;
- int a, i, j, d, n, x, y;
- string komanda[10], str[10000];
- char znak[1000];
- cin >> n >> x >> y;
- for (i=0; i<n; i++)
- {
- cin >> znak[i];
- s = s + znak[i];
- }
- i = y; j = x; a = 3;
- for (int p=0; p<s.length(); p++)
- {
- if (s[p] == 'L')
- a = a + 1;
- if (s[p] == 'D')
- a = a - 1;
- if (s[p] == 'N')
- {
- d = a % 4;
- switch (d)
- {
- case 1: j=j-1; break;
- case 2: i=i-1; break;
- case 3: j=j+1; break;
- case 0: i=i+1; break;
- case -1: j=j+1; break;
- case -2: i=i-1; break;
- case -3: j=j-1; break;
- }
- }
- }
- cout << j << " " << i << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment