Editorial for Yet Another Contest 4 P1 - Snap


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.

Author: Josh

Subtask 1

We can brute force through all \mathcal{O}(N) possible ways to cut the cards, and simulate each of them in \mathcal{O}(N) time.

Time complexity: \mathcal{O}(N^2)

Subtask 2

The key observation is that cutting the cards has no impact on the number of rounds with matching cards. This is because no matter how the cards are cut, the pairs of cards which are placed together will always be the same.

This means that we can ignore cutting the cards completely, and simulate the game once.

Time complexity: \mathcal{O}(N)


Comments

There are no comments at the moment.