Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.IO;
  4. using System.Text;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7.  
  8. /**
  9. * Auto-generated code below aims at helping you parse
  10. * the standard input according to the problem statement.
  11. **/
  12. class Player
  13. {
  14. static void Main(string[] args)
  15. {
  16. string[] inputs;
  17. inputs = Console.ReadLine().Split(' ');
  18. int W = int.Parse(inputs[0]); // width of the building.
  19. int H = int.Parse(inputs[1]); // height of the building.
  20. int N = int.Parse(Console.ReadLine()); // maximum number of turns before game over.
  21. inputs = Console.ReadLine().Split(' ');
  22. int X0 = int.Parse(inputs[0]);
  23. int Y0 = int.Parse(inputs[1]);
  24.  
  25. int xMin = 0;
  26. int yMin = 0;
  27. int xMax = W -1;
  28. int yMax = H - 1;
  29.  
  30. // game loop
  31. while (true)
  32. {
  33. string bombDir = Console.ReadLine(); // the direction of the bombs from batman's current location (U, UR, R, DR, D, DL, L or UL)
  34.  
  35.  
  36. if (bombDir.Contains("U")){
  37. yMax = Y0 - 1;
  38. } else if (bombDir.Contains("D")){
  39. yMin = Y0 + 1;
  40. }
  41.  
  42. if (bombDir.Contains("R")){
  43. xMin = X0 + 1;
  44. } else if (bombDir.Contains("L")){
  45. xMax = X0 - 1;
  46. }
  47.  
  48. X0 = (xMin + xMax)/2;
  49. Y0 = (yMin + yMax)/2;
  50.  
  51. // Write an action using Console.WriteLine()
  52. // To debug: Console.Error.WriteLine("Debug messages...");
  53.  
  54. string returnedValue = X0.ToString() + " " + Y0.ToString();
  55. // the location of the next window Batman should jump to.
  56. Console.WriteLine(X0 + " " + Y0);
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement