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.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Subtask 1
We can brute force through all possible ways to cut the cards, and simulate each of them in time.
Time complexity:
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:
Comments