Baltic Olympiad in Informatics: 2017 Day 2, Problem 1
High school is all about being in the coolest group of friends.
Headmistress Umbridge knows this, and she also knows that knowledge is power.
She has collected data on all of the
From anonymous (but highly reliable) sources, Headmistress Umbridge knows that the friendships at her school satisfy the following properties:
- If
is friends with then is also friends with . - The set of students can be partitioned into groups, such that every student participates in exactly one group, where
- each group has at least one and at most
students, and - for each group there are at most
pairs of friends with the first one in the group, and the second one outside of it.
- each group has at least one and at most
Note that two students in the same group do not have to be friends.
Umbridge has hired you to figure out whether it is possible that all students are telling the truth, or whether she can be sure that at least one student is lying, and that she therefore should put everyone in detention. Is this morally questionable? Probably.
(In case the students may be telling the truth, you are worried that her suspicion might fall on you instead; thus you will also want to provide evidence of a valid partition if there is one.)
Input Specification
First a single line with three non-negative integers
Constraints
We always have
- Group 1: 20 points
- Group 2: 37 points
and - Group 3: 12 points
- Group 4: 31 points No further restrictions.
Output Specification
If Dolores can be certain someone didn't tell the truth, output detention
.
Otherwise, output home
.
If you output home
on the first line, then you should prove your claim by outputting a partition of the students into groups such that the requirements above hold (if there are several, any one will do):
The second line should then contain a positive integer
Sample Input 1
4 2 1
1 1
2 0 2
2 1 3
1 2
Sample Output 1
home
2
2 0 1
2 2 3
Sample Input 2
5 2 1
1 1
2 0 2
2 1 3
2 2 4
1 3
Sample Output 2
detention
Sample Input 3
3 3 3
2 1 2
2 0 2
1 0
Sample Output 3
detention
Comments