Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- class Program
- {
- static void Main(string[] args)
- {
- int size = int.Parse(Console.ReadLine());
- int[] field = new int[size];
- int[] indexes = Console.ReadLine().Split().Select(int.Parse).ToArray();
- foreach (var index in indexes)
- {
- if (index < field.Length)
- {
- field[index] = 1;
- }
- }
- string[] input = Console.ReadLine().Split().ToArray();
- while (input[0] != "end")
- {
- int indexToMove = int.Parse(input[0]);
- bool indexOutOfRange = indexToMove < 0 || indexToMove > field.Length - 1;
- bool ladybugMiss = field[indexToMove] == 0;
- if (indexOutOfRange || ladybugMiss)
- {
- input = Console.ReadLine().Split().ToArray();
- continue;
- }
- string direction = input[1];
- int fly = int.Parse(input[2]);
- if (fly < 0)
- {
- if (direction == "right")
- {
- direction = "left";
- }
- else
- {
- direction = "right";
- }
- fly = Math.Abs(fly);
- }
- input = Console.ReadLine().Split().ToArray();
- }
- Console.WriteLine(string.Join(" ", field));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement