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;
- using System.Text.RegularExpressions;
- namespace _02.ArrayManipulator
- {
- class ArrayManipulator
- {
- static void Main(string[] args)
- {
- var dict = new Dictionary<int, bool>();
- var fields = int.Parse(Console.ReadLine());
- for (int i = 0; i < fields; i++) dict[i] = false;
- var ladies = Console.ReadLine().Split().Select(int.Parse).ToArray();
- foreach (var item in ladies)
- if (dict.ContainsKey(item)) dict[item] = true;
- var input = Console.ReadLine();
- while (input != "end")
- {
- var tempInp = input.Split().ToArray();
- var from = int.Parse(tempInp[0]);
- var to = int.Parse(tempInp[2]);
- var direction = tempInp[1];
- if (direction == "right")
- {
- try
- {
- if (dict[from] == true)
- {
- while (true)
- {
- dict[from] = false;
- try
- {
- if (dict[from + to] == false)
- {
- dict[from + to] = true;
- break;
- }
- else
- {
- to += to;
- }
- }
- catch (Exception) { break; }
- }
- }
- }
- catch (Exception) { }
- }
- else
- {
- try
- {
- if (dict[from] == true)
- {
- while (true)
- {
- dict[from] = false;
- try
- {
- if (dict[from + (to * -1)] == false)
- {
- dict[from + (to * -1)] = true;
- break;
- }
- else
- {
- to += to;
- }
- }
- catch (Exception) { break; }
- }
- }
- }
- catch (Exception) { }
- }
- input = Console.ReadLine();
- }
- foreach (var item in dict)
- {
- if (item.Value == true)
- {
- Console.Write("1 ");
- }
- else
- {
- Console.Write("0 ");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement