ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Разделы > Linear Data Structures: Arrays > задача:


51131 - Running After a Thief

Гость
• Вопросы к жюри (1)

Задачи раздела

• 51069 - Last Digit of a Fibonacci Nu...
• 51073 - Campus Tours for High Sch...
• 51148 - Circles
• 51123 - Mr. Li Criteria
• 51124 - Easy Tiae words
• 51145 - Graduation Exam
• 51117 - The Most Crowded
• 51146 - Popular Baby Names
• 51131 - Running After a Thief
• 51143 - Departments Competition
• 50994 - The Most Crowded Station
• 51118 - Place 7 to the 5th position
• 51132 - Problem Solving Competition
• 51121 - Complexity power of a nu...
• 51119 - Evaluating Prefix expressions
• 50563 - Modul i gjate
• 50594 - Transformimet

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ibrahim Mesecan.

Running After a Thief

Police is running after a thief. They think that the thief is trying to hide himself and very few people know him. Possible candidates are known in the region by less than a number given (k).

Question: Write a program that will read list of people and a list of friendship relations. Then, the program lists possible candidates which are known by less than k people.

Input specification: In the beginning, you will be given two integers: number of people (n), and maximum number of friends (k). Next n lines give the list of people. Following line has an integer (m) number of connections. Each of next m lines contains two names who know each other. Names are at most 20 chars containing only 26 uppercase or lowercase English letters; 1 ≤ k ≤ n ≤ 5,000 and 1 ≤ m ≤ 30,000. Note that a person cannot be the friend of himself. As in the example Jonara knows herself too, but this is not count as another person.

Output specification: First show the number of possible candidates. Then, show the list of people in each line. The order of names is not important. You can print names in any order.

Sample Input Sample Output
6 3
Nail
Klajd
Imelda
Jonara
Lori
Luela
10
Imelda Lori
Lori Nail
Jonara Imelda
Nail Luela
Klajd Nail
Jonara Lori
Klajd Imelda
Lori Jonara
Jonara Jonara
Luela Lori
3
Jonara
Klajd
Luela
                       
People and their friendship list
Nail ==> Lori Luela Klajd
Klajd ==> Imelda Nail
Imelda ==> Lori Klajd Jonara
Jonara ==> Lori Imelda
Lori ==> Luela Jonara Nail Imelda
Luela ==> Lori Nail

Explanation: Maximum number given is 3. Lori has 4 friends; Nail and Imelda have 3 friends; Jonara, Klajd and Luela have two friends. Thus, according to the given criteria, Jonara, Klajd and Luela are possible candidates.



Для отправки решений необходимо выполнить вход.

www.contester.ru