Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 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. using System.Text.RegularExpressions;
  7.  
  8. namespace _02.ArrayManipulator
  9. {
  10. class ArrayManipulator
  11. {
  12. static void Main(string[] args)
  13. {
  14.  
  15. var dict = new Dictionary<int, bool>();
  16. var fields = int.Parse(Console.ReadLine());
  17.  
  18. for (int i = 0; i < fields; i++) dict[i] = false;
  19.  
  20. var ladies = Console.ReadLine().Split().Select(int.Parse).ToArray();
  21. foreach (var item in ladies)
  22. if (dict.ContainsKey(item)) dict[item] = true;
  23. var input = Console.ReadLine();
  24. while (input != "end")
  25. {
  26. var tempInp = input.Split().ToArray();
  27. var from = int.Parse(tempInp[0]);
  28. var to = int.Parse(tempInp[2]);
  29. var direction = tempInp[1];
  30.  
  31.  
  32. if (direction == "right")
  33. {
  34. try
  35. {
  36. if (dict[from] == true)
  37. {
  38. while (true)
  39. {
  40. dict[from] = false;
  41. try
  42. {
  43. if (dict[from + to] == false)
  44. {
  45. dict[from + to] = true;
  46. break;
  47. }
  48. else
  49. {
  50. to += to;
  51. }
  52. }
  53. catch (Exception) { break; }
  54. }
  55. }
  56. }
  57. catch (Exception) { }
  58. }
  59. else
  60. {
  61. try
  62. {
  63. if (dict[from] == true)
  64. {
  65. while (true)
  66. {
  67. dict[from] = false;
  68. try
  69. {
  70. if (dict[from + (to * -1)] == false)
  71. {
  72. dict[from + (to * -1)] = true;
  73. break;
  74. }
  75. else
  76. {
  77. to += to;
  78. }
  79. }
  80. catch (Exception) { break; }
  81. }
  82. }
  83. }
  84. catch (Exception) { }
  85. }
  86. input = Console.ReadLine();
  87. }
  88. foreach (var item in dict)
  89. {
  90. if (item.Value == true)
  91. {
  92. Console.Write("1 ");
  93. }
  94. else
  95. {
  96. Console.Write("0 ");
  97. }
  98. }
  99. }
  100. }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement