Problem 6. Wardrobe
Оценката на чичко "Джъдж": три валидни нулеви теста и 0 точки от другите тестове:
using System;
using System.Collections.Generic;
namespace Problem_6._Wardrobe
{
class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
Dictionary<string, Dictionary<string, int>> colors = new Dictionary<string, Dictionary<string, int>>();
for (int i = 0; i < n; i++)
{
string[] input = Console.ReadLine()
.Split(new string[] { ",", " -> ", ", " }, StringSplitOptions.RemoveEmptyEntries);
string color = input[0];
if (!colors.ContainsKey(color))
{
colors.Add(color, new Dictionary<string, int>());
foreach (var clothes in input)
{
if (clothes != input[0])
{
colors[color].Add(clothes, 1);
}
}
}
else
{
foreach (var clothes in input)
{
if (clothes != input[0])
{
if (!colors[color].ContainsKey(clothes))
{
colors[color].Add(clothes, 1);
}
else
{
colors[color][clothes]++;
}
}
}
}
}
string[] seeking = Console.ReadLine().Split(new[] {" " }, StringSplitOptions.RemoveEmptyEntries);
string seekingColor = seeking[0];
string seekingClothes = seeking[1];
foreach (var kvp in colors)
{
bool seekValidColor = true;
string color = kvp.Key;
if (color != seekingColor)
{
seekValidColor = false;
}
Console.WriteLine($"{color} clothes:");
Dictionary<string, int> clothesList = kvp.Value;
foreach (var kvpClothes in clothesList)
{
bool seekValidClothes = true;
string clothes = kvpClothes.Key;
if (clothes != seekingClothes)
{
seekValidClothes = false;
}
int count = kvpClothes.Value;
if (seekValidColor == true && seekValidClothes == true)
{
Console.WriteLine($"* {clothes} - {count} (found!)");
}
else
{
Console.WriteLine($"* {clothes} - {count}");
}
}
}
}
}
}