Editorial for APIO '07 P3 - Zoo
Submitting an official solution before solving the problem yourself is a bannable offence.
This is a special case of Max-SAT, where each clause can only contain variables which are close together (in a circular order). Specifically:
- Each animal is a boolean variable in Max-SAT. We have
variables in a circular order. - Each child is a clause in Max-SAT. If a child can see
consecutive enclosures, this means that each clause may only contain variables for some (where , and so on). For this problem, we are given .
A model solution uses dynamic programming.
Linear case
Consider a simpler problem when the enclosures
Consider the set of children
, and consider all ways in which the final enclosures may be filled or empty. For each filled/empty combination for enclosures , what is the maximum number of children in who can be made happy?
We solve the problems at stage
- We count how many "new" children in
are made happy. We can calculate this directly from our choice of filled/empty values for , because every "new" child is looking at precisely these enclosures. - Assuming the "old" enclosure
is filled, we can look up our solutions from stage to find out how many children in can be made happy with our selected filled/empty values for . Likewise, we can look up how many children in can be made happy when the old enclosure is empty. The larger of these two numbers tells us how many "old" children in we can keep happy overall. - The number of happy "new" children from step 1 can be added to the number of happy "old" children from step 2, giving the solution to our current problem.
The total number of problems to solve is
Circular case
In the circular case, we need to permanently remember the states of the first
We therefore have
Comments