Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Robot_p42
- {
- class Program
- {
- static void Main(string[] args)
- {
- int x, y;
- string s = "";
- readInput(out x, out y, out s);
- task(ref x, ref y, s);
- Console.WriteLine(x + " " + y);
- }
- static void task(ref int x, ref int y, string s)
- {
- int step = 0;
- foreach (char buoc in s)
- {
- if (step == 4) step = 0;
- else if (step == -1) step = 3;
- move(step, buoc, ref x, ref y);
- if (buoc == 'L') step++;
- else if (buoc == 'R') step--;
- }
- }
- static void move(int mat, char buoc, ref int x, ref int y)
- {
- if (mat == 0)
- {
- if (buoc == 'F') x++;
- else if (buoc == 'B') x--;
- else if (buoc == 'R') y--;
- else if (buoc == 'L') y++;
- }
- else if (mat == 1)
- {
- if (buoc == 'F') y++;
- else if (buoc == 'B') y--;
- else if (buoc == 'R') x++;
- else if (buoc == 'L') x--;
- }
- else if (mat == 2)
- {
- if (buoc == 'F') x--;
- else if (buoc == 'B') x++;
- else if (buoc == 'R') y++;
- else if (buoc == 'L') y--;
- }
- else if (mat == 3)
- {
- if (buoc == 'F') y--;
- else if (buoc == 'B') y++;
- else if (buoc == 'R') x--;
- else if (buoc == 'L') x++;
- }
- }
- static void readInput(out int x, out int y, out string s)
- {
- string[] temp = Console.ReadLine().Split();
- x = int.Parse(temp[0]);
- y = int.Parse(temp[1]);
- s = Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement