Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- using System.Linq;
- using System.Globalization;
- using System.Collections.Generic;
- using System.Text;
- public class Example
- {
- public static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- Dictionary<string, List<string>> valid = new Dictionary<string, List<string>>();
- Regex r = new Regex(@"^[A-Za-z]{5,}@[a-z]{3,}(\.com|\.bg|\.org)$");
- for (int i = 0; i < n; i++)
- {
- string input = Console.ReadLine();
- if (!r.Match(input).Success)
- {
- continue;
- }
- string[] splt = input.Split('@').ToArray();
- if (valid.ContainsKey(splt[1]))
- {
- if (valid[splt[1]].Any(t => t == splt[0]))
- {
- continue;
- }
- valid[splt[1]].Add(splt[0]);
- }
- else
- {
- valid.Add(splt[1], new List<string>() { splt[0] });
- }
- }
- foreach (var domain in valid.OrderByDescending(t => t.Value.Count))
- {
- Console.WriteLine($"{domain.Key}:");
- foreach (var user in domain.Value)
- {
- Console.WriteLine($"### {user}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement