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 MultiDictionaries
- {
- class Program
- {
- static void Main(string[] args)
- {
- var continentsData= new Dictionary<string,Dictionary<string,List<string>>();
- int inputCount = int.Parse(Console.ReadLine());
- for(int i = 0; i < inputCount; i++)
- {
- string[] input = Console.ReadLine().Split(' ');
- string continentName = input[0];
- string countryName = input[1];
- List<string> cityName = input[2];
- if(!continentsData.ContainsKey(continentName))
- {
- continentsData.Add(continentName, new Dictionary<string, string>());
- }
- continentsData[continentName].Add(countryName, cityName);
- }
- foreach(var record in continentsData)
- {
- string continentName = record.Key;
- Dictionary<string, string> countriesData = record.Value;
- Console.WriteLine("{0}:", continentName);
- foreach(KeyValuePair<string, string> countryData in countriesData)
- {
- string countryName = countryData.Key;
- string cityNames = countryData.Value;
- Console.WriteLine(" {0} --> {1}", countryName, cityNames);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment