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;
- class Slides
- {
- static void Main()
- {
- string[] measures = Console.ReadLine().Split(' ');
- int w = int.Parse(measures[0]);
- int h = int.Parse(measures[1]);
- int d = int.Parse(measures[2]);
- string[,,] cube = new string[w,h,d];
- ReadingAndInput(cube, h);
- string[] dropPoint = Console.ReadLine().Split(' ');
- int[] position = {int.Parse(dropPoint[0]),0,int.Parse(dropPoint[1])};
- Moving(position,cube);
- }
- static void Moving(int[] position,string[,,] cube)
- {
- while (true)
- {
- bool yes = false;
- int[] currPosition = new int[3];
- Array.Copy(position, currPosition,3);
- char move = cube[position[0], position[1], position[2]][1];
- switch(move)
- {
- case 'S': Slide(cube[position[0], position[1], position[2]],position); break;
- case 'T': Teleport(cube[position[0], position[1], position[2]], position); break;
- case 'E': position[1]++;break;
- case 'B': Printing(currPosition,yes);break;
- }
- if (move == 'B') break;
- if (position[0]<0 || position[0]>=cube.GetLength(0) || (position[1]==cube.GetLength(1)&&move=='S')
- || position[2] < 0 || position[2] >= cube.GetLength(2) || position[1] > cube.GetLength(1))
- {
- if (position[1] >= cube.GetLength(1)) yes = true;
- Printing(currPosition,yes);
- break;
- }
- }
- }
- static void Printing(int[] endPosition,bool end)
- {
- if (end)
- {
- Console.WriteLine("Yes");
- Console.WriteLine(string.Join(" ",endPosition));
- }
- else
- {
- Console.WriteLine("No");
- Console.WriteLine(string.Join(" ",endPosition));
- }
- }
- static void Teleport(string move, int[] position)
- {
- position[0] = int.Parse(move[3].ToString());
- position[2] = int.Parse(move[5].ToString());
- }
- static void Slide(string move,int[] position)
- {
- for (int i = 3; i <= 4; i++)
- {
- switch (move[i])
- {
- case 'L': position[0]--; break;
- case 'R': position[0]++; break;
- case 'B': position[2]++; break;
- case 'F': position[2]--; break;
- }
- }
- position[1]++;
- }
- static void ReadingAndInput(string[,,] cube, int hh)
- {
- for (int h = 0; h < hh; h++)
- {
- string inputRow = Console.ReadLine();
- int openBracket = 0;
- int closeBracket = inputRow.IndexOf(")");
- for (int d = 0; d < cube.GetLength(2); d++)
- {
- for (int w = 0; w < cube.GetLength(0); w++)
- {
- cube[w,h,d] = inputRow.Substring(openBracket,closeBracket+1-openBracket);
- openBracket = inputRow.IndexOf("(", closeBracket);
- if (openBracket < 0) break;
- closeBracket = inputRow.IndexOf(")",openBracket);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement