+ Нов въпрос
Nikodon 3 Точки

## Nikulden's meal

Привет, опитвам се да реша въпросната задача.

Докарах я до 70/100 , изкарвам Outputa , но джъдж не ми дава 100/100.

Може ли някой да помогне ако може?

Освен това имам въпрос по парче от кода.

Става дума за ред 42

Първоначално го бях написал както е в закодираната чст и не работеше, а сега след корекцията проработи.

Не мога да си обясня разликата м/у двете. В закодираната част търсих точно ястието , което го няма , но в крайна сметка не работеше така.

Но дори и така пак дава 70/100.

Ще бъда благодарен на малко помощ.

Пускам кода и условието:

https://pastebin.com/nwEwBSjQ

Nikulden’s meals

Now you want to find out which meals your guests liked and how many meals they didn't like

Create a program that keeps information about guests liked and unliked meals.

You will be receiving lines with commands until you receive the "Stop" command. The possible commands are:

• Add the {mea1} to the {guest}’s collection of meals.
• If the guest doesn't exist, add it to your record.
• If the guest already has the meal in his collection, don’t add it.
• Remove  the meal of the given guest’s collection and print:

"{Guest} doesn't like the {meal}."

You must keep the count of unliked meals!

• If the guest doesn’t exist, print:

"{Guest} is not at the party."

• If the guest doesn’t have the meal at the like list, print:

"{Guest} doesn't have the {meal} in his/her collection."

In the end, you have to print the guests with their liked meals sorted in descending order by each guest meals count and then by their names in ascending order. Then print the count of unliked meals in the format below

{Guest1}: {meal1}, {meal2}, {meal3}

{Guest2}: {meal1}, {meal2}

...

Unliked meals: {count of all unliked meals}

Input

• You will be receiving lines until you receive the "Stop" command.
• The input will always be valid.

## Output

• Print the guests with their meals in the format described above.
• Print the count of unliked meals in the format described above.

## Examples

 Input Output Like-Krisi-shrimps Like-Krisi-soup Like-Misho-salad Like-Pena-dessert Stop Krisi: shrimps, soup Misho: salad Pena: dessert Unliked meals: 0 Input Output Like-Krisi-shrimps Unlike-Vili-carp Unlike-Krisi-salad Unlike-Krisi-shrimps Stop Vili is not at the party. Krisi doesn't have the salad in his/her collection. Krisi doesn't like the shrimps. Krisi: Unliked meals: 1
Тагове:
0
nickwork 288 Точки

(!guestMenue.ContainsKey(meal)) - тази команда търси ключ който го няма в колекцията(тук търсим само само ключ в колекцията)

(!guestMenue[guests].Contains(meal)) - тази търси параметър на ключа (в случая ключа тук е guests с параметър meal)

using System;
using System.Collections.Generic;
using System.Linq;

namespace _3._3_Nikulden_s_meals
{
class Program
{
static void Main(string[] args)
{
string command;
Dictionary<string, List<string>> guestMenue = new Dictionary<string, List<string>>();
int count = 0;

while ((command = Console.ReadLine()) != "Stop")
{
string[] commandSplit = command.Split("-", StringSplitOptions.RemoveEmptyEntries).ToArray();
string likeUnlike = commandSplit[0];
string guests = commandSplit[1];
string meal = commandSplit[2];

if (likeUnlike == "Like")
{
{
}
{
}
}

else if (likeUnlike == "Unlike")
{
{
Console.WriteLine(\$"{guests} is not at the party.");

}
{
Console.WriteLine(\$"{guests} doesn't have the {meal} in his/her collection.");
}
else
{
Console.WriteLine(\$"{guests} doesn't like the {meal}.");
count++;
}
}
}

foreach (var kvp in guestMenue.OrderByDescending(kvp => kvp.Value.Count).ThenBy(kvp => kvp.Key))
{
Console.WriteLine(\$"{kvp.Key}: {string.Join(", ", kvp.Value)}");
}

Console.WriteLine(\$"Unliked meals: {count}");
}
}
}

0
Nikodon 3 Точки

Благодаря ти, сега разбрах . Много ми беше полезно :)

1