Advertisement
Guest User

Untitled

a guest
Sep 1st, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.58 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Slides
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string firstLine = Console.ReadLine();
  14.             string[] borders = firstLine.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  15.             int witdth = int.Parse(borders[0]);
  16.             int height = int.Parse(borders[1]);
  17.             int depth = int.Parse(borders[2]);
  18.             List<string> cubes = new List<string>();
  19.             string[,,] cube = new string[witdth,height,depth];
  20.             string input = "";
  21.             int counter = 0;
  22.  
  23.             for (int i = 0; i < height; i++)
  24.             {
  25.                 input = Console.ReadLine();
  26.                 borders = input.Split(new string[] {" | " , "(" , ")"}, StringSplitOptions.RemoveEmptyEntries);
  27.                 for (int j = 0; j < borders.Length; j++)
  28.                 {
  29.                     cubes.Add(borders[j]);
  30.                 }
  31.             }
  32.             counter = 0;
  33.  
  34.             for (int heights = 0; heights < cube.GetLength(1); heights++)
  35.             {
  36.                 for (int depths = 0; depths < cube.GetLength(2); depths++)
  37.                 {
  38.                     for (int witdths = 0; witdths < cube.GetLength(0); witdths++)
  39.                     {
  40.                         if (cubes[counter] != " ")
  41.                         {
  42.                             cube[witdths, heights, depths] = cubes[counter];
  43.                         }
  44.                         else
  45.                         {
  46.                             while (cubes[counter] == " ")
  47.                             {
  48.                                 counter++;
  49.                             }
  50.                             cube[witdths, heights, depths] = cubes[counter];
  51.  
  52.                         }
  53.                         counter++;
  54.                     }
  55.                 }  
  56.             }
  57.  
  58.             input = Console.ReadLine();
  59.             int ballW = input[0] - 48;
  60.             int ballD = input[2] - 48;
  61.             int ballH = 0;
  62.             int oldW = 0;
  63.             int oldD = 0;
  64.             int oldH = 0;
  65.  
  66.             while (true)
  67.             {
  68.                 oldD = ballD;
  69.                 oldW = ballW;
  70.                 oldH = ballH;
  71.                 if (cube[ballW,ballH,ballD] == "S L")
  72.                 {
  73.                     ballW--;
  74.                     ballH++;
  75.                 }
  76.                 else if (cube[ballW,ballH,ballD] == "S R")
  77.                 {
  78.                     ballW++;
  79.                     ballH++;
  80.                 }
  81.                 else if (cube[ballW, ballH, ballD] == "S B")
  82.                 {
  83.                     ballD++;
  84.                     ballH++;
  85.                      
  86.                 }
  87.                 else if (cube[ballW, ballH, ballD] == "S FL")
  88.                 {
  89.                     ballW--;
  90.                     ballD--;
  91.                     ballH++;
  92.                 }
  93.                 else if (cube[ballW, ballH, ballD] == "S FR")
  94.                 {
  95.                     ballW++;
  96.                     ballD--;
  97.                     ballH++;
  98.                 }
  99.                 else if (cube[ballW, ballH, ballD] == "S Bl")
  100.                 {
  101.                     ballW--;
  102.                     ballD++;
  103.                     ballH++;
  104.                 }
  105.                 else if (cube[ballW, ballH, ballD] == "S BR")
  106.                 {
  107.                     ballW++;
  108.                     ballD++;
  109.                     ballH++;
  110.                 }
  111.                 else if (cube[ballW, ballH, ballD] == "E")
  112.                 {
  113.                     ballH++;
  114.                 }
  115.                 else if (cube[ballW, ballH, ballD] == "S F")
  116.                 {
  117.                     ballD--;
  118.                     ballH++;
  119.                 }
  120.                 else if (cube[ballW, ballH, ballD] == "B")
  121.                 {
  122.                     Console.WriteLine("No");
  123.                     Console.WriteLine("{0} {1} {2}", oldW, oldH, oldD);
  124.                     return;
  125.                 }
  126.  
  127.                 else if (cube[ballW, ballH, ballD][0] == 'T')
  128.                 {
  129.                     borders = cube[ballW, ballH, ballD].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  130.                     ballW = int.Parse(borders[1]);
  131.                     ballD = int.Parse(borders[2]);
  132.                 }
  133.  
  134.                 if ((ballW == -1 || ballW == cube.GetLength(0)) && ballH == cube.GetLength(1))
  135.                 {
  136.                     Console.WriteLine("Yes");
  137.                     Console.WriteLine("{0} {1} {2}", oldW, oldH, oldD);
  138.                     return;
  139.                 }
  140.  
  141.                 else if (ballW == -1 || ballW == cube.GetLength(0))
  142.                 {
  143.                     Console.WriteLine("No");
  144.                     Console.WriteLine("{0} {1} {2}", oldW, oldH, oldD);
  145.                     return;
  146.                 }
  147.  
  148.                 if ((ballD == -1 || ballD == cube.GetLength(2)) && ballH == cube.GetLength(1))
  149.                 {
  150.                     Console.WriteLine("Yes");
  151.                     Console.WriteLine("{0} {1} {2}", oldW, oldH, oldD);
  152.                     return;
  153.                 }
  154.  
  155.                 else if (ballD == -1 || ballD == cube.GetLength(2))
  156.                 {
  157.                     Console.WriteLine("No");
  158.                     Console.WriteLine("{0} {1} {2}", oldW, oldH, oldD);
  159.                     return;
  160.                 }
  161.                 if (ballH == cube.GetLength(1))
  162.                 {
  163.                     Console.WriteLine("Yes");
  164.                     Console.WriteLine("{0} {1} {2}", oldW, oldH, oldD);
  165.                     return;
  166.                 }
  167.             }
  168.             //for (int witdths = 0; witdths < cube.GetLength(0); witdths++)
  169.             //{
  170.             //    for (int heights = 0; heights < cube.GetLength(1); heights++)
  171.             //    {
  172.             //        for (int depths = 0; depths < cube.GetLength(2); depths++)
  173.             //        {
  174.             //            Console.Write(cube[witdths, heights, depths] + "'");
  175.             //        }
  176.             //        Console.WriteLine();
  177.             //    }
  178.             //}
  179.             //for (int i = 0; i < cubes.Count; i++)
  180.             //{
  181.             //    borders = cubes[i].Split(new char[] { '(', ')' }, StringSplitOptions.RemoveEmptyEntries);
  182.             //    foreach (var item in borders)
  183.             //    {
  184.             //        Console.Write(item);
  185.             //    }
  186.             //    Console.WriteLine();
  187.             //}
  188.  
  189.  
  190.         }
  191.     }
  192. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement