Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- class Program
- {
- static void Main(string[] args)
- {
- List<string> list = new List<string>(Console.ReadLine().Split(" "));
- int n = int.Parse(Console.ReadLine());
- for (int i = 0; i < n; i++)
- {
- string[] tokens = Console.ReadLine().Split(" ");
- string command = tokens[0];
- if (command == "Include")
- {
- string shop = tokens[1];
- list.Add(shop);
- }
- else if (command == "Visit")
- {
- int count = int.Parse(tokens[2]);
- if (list.Count >= count)
- {
- if (tokens[1] == "first")
- {
- list.RemoveRange(0, count);
- }
- else if (tokens[1] == "last")
- {
- list.RemoveRange(list.Count - count, count);
- }
- }
- }
- else if (command == "Prefer")
- {
- int index1 = int.Parse(tokens[1]);
- int index2 = int.Parse(tokens[2]);
- if (index1 >= 0 && index1 < list.Count && index2 >= 0 && index2 < list.Count)
- {
- string temp = list[index1];
- list[index1] = list[index2];
- list[index2] = temp;
- }
- }
- else if (command == "Place")
- {
- string shop = tokens[1];
- int index = int.Parse(tokens[2]);
- if (index >= 0 && index <= list.Count)
- {
- list.Insert(index + 1, shop);
- }
- }
- }
- Console.WriteLine($"Shops left:");
- Console.WriteLine(string.Join(" ", list));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement