Editorial for DMOPC '19 Contest 5 P6 - Cecilia's Computational Crisis
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
For the first subtask, it suffices to brute force all ways of replacing each ?
with either an X
or a .
and checking if the resulting plan is efficient.
Time complexity:
For the second subtask, let's assume ?
in either string. Then clearly there is an efficient plan if the strings are different and no efficient plan if the strings are equal. If there is a single ?
in either string, there is always an efficient plan.
Time complexity:
For the third subtask, observe that rows with more than ?
can be ignored due to Hall's marriage theorem. It essentially states that, each row that can yield at least ?
with .
or X
can be ignored because they can always be matched to one of these rows. Therefore, if we ignore rows that don't satisfy the limit, each row contains at most ?
. Therefore, it suffices to brute force all of these assignments as well.
Time complexity:
Using the same observation as the previous subtask, we can remove all rows with more than ?
. Now, each row can yield at most
Time complexity:
Comments