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 Ball
- {
- private int width;
- private int depth;
- private int height = 0;
- public Ball(int width, int depth)
- {
- this.width = width;
- this.depth = depth;
- }
- public int Width
- {
- get { return this.width; }
- set { this.width = value; }
- }
- public int Depth
- {
- get { return this.depth; }
- set { this.depth = value; }
- }
- public int Height
- {
- get { return this.height; }
- set { this.height = value; }
- }
- }
- class Program
- {
- static string[, ,] cube;
- static int cubeWidth, cubeHeight, cubeDepth;
- static int tempBallWidth, tempBallHeight, tempBallDepth;
- static void ReadInput()
- {
- string[] input = Console.ReadLine().Split(' ');
- cubeWidth = int.Parse(input[0]);
- cubeHeight = int.Parse(input[1]);
- cubeDepth = int.Parse(input[2]);
- cube = new string[cubeWidth, cubeHeight, cubeDepth];
- for (int h = 0; h < cubeHeight; h++)
- {
- string[] lineSplit = Console.ReadLine().Split(new string[] { " | " }, StringSplitOptions.RemoveEmptyEntries);
- for (int d = 0; d < cubeDepth; d++)
- {
- string[] sequenceSplit = lineSplit[d].Split(new char[] { '(', ')' }, StringSplitOptions.RemoveEmptyEntries);
- for (int w = 0; w < cubeWidth; w++)
- {
- cube[w, h, d] = sequenceSplit[w];
- }
- }
- }
- }
- static void CheckBallCoordinates(Ball ball)
- {
- int[] ballCoordinates = { ball.Width, ball.Height, ball.Depth };
- bool result = false;
- for (int i = 0; i < ballCoordinates.Length; i++)
- {
- if (ballCoordinates[i] == -1)
- {
- result = true;
- break;
- }
- if (ballCoordinates[i] >= cubeWidth || ballCoordinates[i] >= cubeHeight || ballCoordinates[i] >= cubeDepth)
- {
- result = true;
- break;
- }
- }
- if (result)
- {
- if (ball.Height >= cubeHeight)
- {
- Console.WriteLine("Yes\n{0} {1} {2}", tempBallWidth, tempBallHeight, tempBallDepth);
- Environment.Exit(0);
- }
- else
- {
- Console.WriteLine("No\n{0} {1} {2}", tempBallWidth, tempBallHeight, tempBallDepth);
- Environment.Exit(0);
- }
- }
- }
- static void Main()
- {
- ReadInput();
- string[] ballInput = Console.ReadLine().Split(' ');
- Ball ball = new Ball(int.Parse(ballInput[0]), int.Parse(ballInput[1]));
- while (true)
- {
- string[] currentPosition = cube[ball.Width, ball.Height, ball.Depth].Split(' ');
- //Keeps old coordinates of the ball
- tempBallWidth = ball.Width;
- tempBallHeight = ball.Height;
- tempBallDepth = ball.Depth;
- //
- string currentCommand = currentPosition[0];
- if (currentCommand == "S")
- {
- ball.Height++;
- switch (currentPosition[1])
- {
- case "L":
- ball.Width--; CheckBallCoordinates(ball); break;
- case "R":
- ball.Width++; CheckBallCoordinates(ball); break;
- case "F":
- ball.Depth--; CheckBallCoordinates(ball); break;
- case "B":
- ball.Depth++; CheckBallCoordinates(ball); break;
- case "FL":
- ball.Depth--; ball.Width--; CheckBallCoordinates(ball); break;
- case "FR":
- ball.Depth--; ball.Width++; CheckBallCoordinates(ball); break;
- case "BL":
- ball.Depth++; ball.Width--; CheckBallCoordinates(ball); break;
- case "BR":
- ball.Depth++; ball.Width++; CheckBallCoordinates(ball); break;
- default:
- break;
- }
- }
- else if (currentCommand == "T")
- {
- ball.Width = int.Parse(currentPosition[1]);
- ball.Depth = int.Parse(currentPosition[2]);
- CheckBallCoordinates(ball);
- }
- else if (currentCommand == "E")
- {
- ball.Height++;
- CheckBallCoordinates(ball);
- }
- else if (currentCommand == "B")
- {
- Console.WriteLine("No\n{0} {1} {2}", ball.Width, ball.Height, ball.Depth);
- Environment.Exit(0);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement