Editorial for TLE '17 Contest 2 P5 - Crew Selection Test
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
For the first subtask, it is enough to print C 1 2. Either these people know each other or they don't. In either case, the crew will work together flawlessly.
For the second subtask, it is enough to make the  queries 
A 1 A 2 A 3 A 4 A 5. Now, the first  people form a complete graph, and we can apply this theorem on Wikipedia. Therefore, it is always possible to select a crew from the first 
 people. We can use brute force to find a crew.
For the third subtask, make the queries A 1 … A 80, then use brute force to find a crew. It is always possible to find a crew.
The fourth subtask is troll.
For the fifth subtask, the intended solution is to solve a more general version of the problem. Create a function  where 
 is a set of people, 
 is an integer, and 
 is another integer. This function returns a subset of 
 that satisfies one of the following conditions:
is a subset of
containing
people, and everyone in this subset knows each other.
is a subset of
containing
people, and everyone in this subset does not know each other.
The answer to the problem is .
You may find it easier to make  a recursive function.
You may find this proof of Ramsey's Theorem to be helpful in coding .
Let  and 
. Also, for 
 and 
, let 
.
We show that for all  and 
, any set of 
 people would satisfy at least one of these conditions:
- There exists a crew of size 
that know each other
 - There exists a crew of size 
that don't know each other
 
The case where  or 
 is easy. The set is size 
. Pick this person from the set, and make a crew.
Let's solve the case where  and 
. Assume that 
 and 
 are already proven.
Ask the first person. Put all of the known people into a set , and all of the unknown people into set 
. Note that 
 and 
. So we have 
.
Since , we must have 
 or 
. So we have two cases.
- Case 1: 
. We can use
to create two cases.
- Case 1a: We can find 
people in
that don't know each other. In this case, we are already done.
 - Case 1b: There are 
people in
that know each other. The first person knows everyone in
, so we can form a crew with the first person and the
people in
. Then there is a crew of
people that know each other, and we are done.
 
 - Case 1a: We can find 
 - Case 2: 
. We can use
to create two cases.
- Case 2a: We can find 
people in
that know each other. In this case, we are already done.
 - Case 2b: There are 
people in
that don't know each other. The first person doesn't know anyone in
, so we can form a crew with the first person and the
people in
. Then there is a crew of
people that don't know each other, and we are done.
 
 - Case 2a: We can find 
 
The last step is to use induction to finish off the proof. This step is easy and is left to the reader as a short exercise.
Note 1: You may notice that . So in the function 
, you should have 
.
Note 2: You may notice that  in all subtasks (so a solution always exists).
Note 3: We need to ask at most  times. This is okay because 
 in all subtasks.
Comments