Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.Linq;
- using System.Collections.Generic;
- namespace SoftUniExamResults
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, List<string>> map =
- new Dictionary<string, List<string>>();
- while (true)
- {
- string input = Console.ReadLine();
- if (input=="Lumpawaroo")
- {
- break;
- }
- string[] checkedForceUsers = input.Split(new string[] { " | ", " -> " }, StringSplitOptions.RemoveEmptyEntries);
- if (input.Contains("|"))
- {
- string forceSide = checkedForceUsers[0];
- string forceUser = checkedForceUsers[1];
- if (!map.ContainsKey(forceSide))
- {
- map.Add(forceSide, new List<string>());
- }
- if (!map.Values.Any(d => d.Contains(forceUser)))
- {
- map[forceSide].Add(forceUser);
- }
- }
- else
- {
- string forceUser = checkedForceUsers[0];
- string forceSide = checkedForceUsers[1];
- foreach (var user in map)
- {
- user.Value.RemoveAll(x=>x == forceUser);
- }
- if (!map.ContainsKey(forceSide))
- {
- map.Add(forceSide, new List<string>());
- }
- if (!map.Values.Any(d => d.Contains(forceUser)))
- {
- map[forceSide].Add(forceUser);
- Console.WriteLine($"{forceUser} joins the {forceSide} side!");
- }
- }
- }
- foreach (var item in map
- .Where(x=>x.Value.Count > 0)
- .OrderByDescending(x=>x.Value.Count)
- .ThenBy(x=>x.Key))
- {
- Console.WriteLine($"Side: {item.Key}, Members: {item.Value.Count}");
- foreach (var user in item.Value.OrderBy(x=>x))
- {
- Console.WriteLine($"! {user}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment