0239. Student's Morning
Имя входного файла: | students.in |
Имя выходного файла: | students.out |
Ограничение по времени: | 1 s |
Ограничение по памяти: | 64 megabytes |
One Monday morning after some very fun party N students woke up at the flat of one of them. Notice that it was a Monday morning and every student of that party needs to be in his university this day. But nobody wants to go to his university alone (there were students from different universities). So, they decided to select from all universities only K of them to visit. Every selected university must be visited by at least two of the students. Every student has his own preference list of universities. It means, if some university is in list of some student's preferred universities, this student can go to this university with some non-empty company of students. Notice, that some of students can stay at the flat and continue drinking "juices" and playing "games". For example, student Shokman was to stay home (due to failed exam) with foreign student Chokman, who remained home because of runny nose.
In that problem there are no preferences between students, because if they have very fun party that already means that everyone of them prefers anybody from this company.
More formally, your task is, given numbers of students, selected universities and preference list of every student, to decide whether it is possible to visit all universities by at least two of students or no, and if it is possible you must output for each university numbers of students, which have to go to it in one company. One student can't be in more than one company.
Input file
First line of input file contains two numbers N and K (0 ≤ K ≤ N ≤ 200). Next N lines contain preference lists of each student. Every preference list is started by number of preferred universities followed by numbers of these universities.
Output file
First line of output file must contain word "YES" (without quotes), if it possible to visit all universities, satisfying rules of that task or word "NO" (also without quotes) when it is impossible. In case of positive answer next N lines must contain lists of students, who are going to corresponding university. First number in list of students must be a number of students in the list, followed by numbers of these students.
Examples:
students.in | students.out |
---|---|
4 2 1 1 2 1 2 1 2 2 1 2 | YES 2 1 2 2 3 4 |
3 2 2 1 2 2 1 2 2 1 2 | NO |
Источник: Petrozavodsk Winter 2004. SPb ETU Contest, Sunday, February 01
Обсудить Отправить решение
Версия для печати