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;
- namespace practic
- {
- class Program
- {
- static void Main(string[] args)
- {
- int size = int.Parse(Console.ReadLine());
- var arrSize = new int[size];
- var ladyBugs = Console.ReadLine().Split().Select(int.Parse).ToArray();
- for (int a = 0; a < arrSize.Length; a++)
- {
- for (int b = 0; b < ladyBugs.Length; b++)
- {
- if (ladyBugs[b] == a)
- {
- arrSize[a] += 1;
- }
- }
- }
- while (true)
- {
- var inpuLine = Console.ReadLine();
- if (inpuLine.Equals("end"))
- {
- break;
- }
- var inpuLineSplit = inpuLine.Split();
- int indexBugs = int.Parse(inpuLineSplit[0]);
- var leftAndRight = inpuLineSplit[1];
- int flightBugs = int.Parse(inpuLineSplit[2]);
- if (indexBugs < 0 || indexBugs >= arrSize.Length)
- {
- continue;
- }
- if (arrSize[indexBugs] == 0)
- {
- continue;
- }
- MoveLadyBugs(arrSize, indexBugs, flightBugs, leftAndRight);
- }
- Console.WriteLine(string.Join(" ", arrSize));
- }
- private static void MoveLadyBugs(int[] arrSize, int indexBugs, int flightBugs, string leftAndRight)
- {
- arrSize[indexBugs] = 0;
- var leftArrayPlace = false;
- while (!leftArrayPlace)
- {
- switch (leftAndRight)
- {
- case "left":
- indexBugs -= flightBugs;
- break;
- case "right":
- indexBugs += flightBugs;
- break;
- }
- if (indexBugs < 0 || indexBugs >= arrSize.Length)
- {
- leftArrayPlace = true;
- continue;
- }
- if (arrSize[indexBugs] == 1)
- {
- continue;
- }
- if (arrSize[indexBugs] == 0)
- {
- arrSize[indexBugs] = 1;
- leftArrayPlace = true;
- continue;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement