## Editorial for Mock CCC '22 Contest 1 J5 - New Year's Restrictions

Remember to use this editorial

**only**when stuck, and**not to copy-paste code from it**. Please be respectful to the problem author and editorialist.**Submitting an official solution before solving the problem yourself is a bannable offence.**For the first subtask, note that the answer is always , , or .

With or being trivial, let's take a look at when .

If the two pairs form a "chain" such as and , we can remove leading to resolutions being kept.

If not, however, we must remove one resolution from each pair, leading to resolutions being kept.

The full solution involves generating all subsets of the resolutions, and checking each restriction to determine if the subset is valid. This can be done in time.

A subtask was given for suboptimal or factorial time solutions.

**Time Complexity:**

## Comments