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

Разделы > Задачи на графах > задача:


50978 - Albanian Coders

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

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

• 50700 - Candidates for the Mayor
• 50692 - How much money?
• 50694 - The Cheapest Flight
• 50841 - My grand-grand-grandfather
• 50697 - Base Stations
• 50695 - Longest link between neurons
• 50414 - Traffic
• 50698 - Ayran Delivery
• 50978 - Albanian Coders
• 50699 - Fighting Vampires
• 50857 - Nine-Stones Game
• 50929 - Present from your uncles
• 51076 - Key person
• 51080 - Deepest Point
• 51079 - Key person - 2
• 50464 - From Tirana to Durres
• 50691 - Задача коммивояжёра

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

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

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

Albanian Coders

The Albanian students, who have been studying for the Olympiads in Informatics, gather around in the school and study on new topics. They have been practicing by typing codes for the Olympiad competitions.

A prominent member of the community is the hardworking student, Ali abi. Every evening, if Ali is present, he teaches a brand new Olympiad subject that no other student has heard before, and no other topic is thought that night. In the event that Ali is not present, other students learn without him and exchange (teach each other) all knowledge (topics) that they know.

Question: Given the list of students present for D consecutive camp days, output all students that know all topics learned during that period.

Input specification: The first line of input contains an integer N, 1 <= N <= 100, the number of students. The students are numbered 1 to N. Student number 1 is Ali. The second line contains an integer D, 1 <= D <= 50, the number of camp days. The next D lines contain the list of students present on each of the D days. Each line begins with a positive integer K, 2 <= K <= N, the number of students present that day, followed by K positive integers separated by spaces representing the students. No student will appear twice in one day and Ali will appear at least once across all nights.

Output specification:
Output all students that know all topics, including Ali, one integer per line in ascending order.

Sample Input I
4
3
2 1 2
3 2 3 4
3 4 2 1
Sample Input II
8
5
4 1 3 5 4
2 5 6
3 6 7 8
2 6 2
4 2 6 8 1
Sample Input III
5
3
2 1 3
2 2 1
4 2 1 4 5
Sample Output I
1
2
4
Sample Output II
1
2
6
8
Sample Output III
1



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

www.contester.ru