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 Light_the_Torches
- {
- class Program
- {
- static void Main()
- {
- int rooms = int.Parse(Console.ReadLine());
- char[] basement = new char[rooms];
- char[] roomsLight = Console.ReadLine().ToArray();
- int index = 0;
- int start = (rooms / 2) ;
- int prays = 0;
- for (int i = 0; i < basement.Length; i++)
- {
- basement[i] = roomsLight[index];
- if (index == roomsLight.Length - 1)
- {
- index = 0;
- }
- else index++;
- }
- while (true)
- {
- string input = Console.ReadLine();
- if (input == "END")
- {
- break;
- }
- string[] inputComb = input.Split(' ');
- int step = int.Parse(inputComb[1]);
- string direction = inputComb[0];
- if (direction=="LEFT")
- {
- if (start - (step + 1) < 0)
- {
- start = 0;
- }
- else start = start - (step + 1);
- if (basement[start] == 'L')
- {
- basement[start] = 'D';
- }
- else basement[start] = 'L';
- }
- if (direction == "RIGHT")
- {
- if (start + (step + 1) > basement.Length-1)
- {
- start = basement.Length - 1;
- }
- else start = start + (step + 1);
- if (basement[start] == 'L')
- {
- basement[start] = 'D';
- }
- else basement[start] = 'L';
- }
- }
- prays = (basement.Count(x=>x=='D')) * (int)'D';
- Console.WriteLine(prays);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement