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

Сборники > Data Structures > задача:


50978 - Albanian Coders

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

Задачи сборника

• 50674 - Collecting Eggs
• 50486 - Problems and Programmers
• 50695 - Longest link between neurons
• 50411 - Sum of the Leaves
• 50677 - The Cottage
• 50795 - Trunk
• 50414 - Traffic
• 50698 - Ayran Delivery
• 50978 - Albanian Coders
• 50699 - Fighting Vampires
• 50830 - Sorting BST Nodes
• 50803 - Sum of the depths in BST
• 50805 - Sum of the weights in a BST
• 50712 - Moon algebra
• 50675 - Kruja Boys
• 50415 - The Scientist
• 50679 - Jetpack Hurdle Jumping

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

Если у вас есть предложения или пожелания по работе 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