Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace ladybug
- {
- class Program
- {
- static void Main(string[] args)
- {
- var size = int.Parse(Console.ReadLine());
- var startindexes = Console.ReadLine().Split().Select(int.Parse).Where(x => x >= 0 && x < size).ToList();
- var field = new int[size];
- foreach (var item in startindexes)
- {
- field[item] = 1;
- }
- while (true)
- {
- var input = Console.ReadLine().Split().ToList();
- if (input[0] == "end")
- {
- break;
- }
- var start = long.Parse(input[0]);
- var direction = input[1];
- var steps = long.Parse(input[2]);
- if (start < 0 || start >= size|| steps > size)
- {
- continue;
- }
- else if (field[start] == 0)
- {
- continue;
- }
- else
- {
- field[start] = 0;
- if (direction == "left")
- {
- steps *= -1;
- }
- long destination = start;
- while (true)
- {
- if (destination + steps >= size)
- {
- break;
- }
- destination += steps;
- if (field[destination] == 1)
- {
- continue;
- }
- else
- {
- field[destination] = 1;
- break;
- }
- }
- }
- }
- Console.WriteLine(String.Join(" ", field));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement