Editorial for LCC '24 Contest 3 S3 - Space Solitaire
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Subtask 1
We can solve this by brute force; Each turn there are at most valid moves you can make, and with
turns there are at most
possibilities.
Time complexity:
Subtask 2
. In no universe are we brute forcing this one.
However, note that at any given turn, there are 7 cards, each with 3 possible states. This means there are a total of configurations every turn. We can thus do dynamic programming; for each turn, keep track of how many possibilities there are for all
configurations.
Indexing a DP array by a state and iterating over every possible state could be difficult. One way of doing this is to number the suits and interpret each state as a base-3 number. Finding a way to extract and/or modify a digit in this number is left as an exercise to the reader.
Time complexity:
(P.S.: If you are tasked with finding an answer "modulo <large prime>", usually , it's most likely a dynamic programming problem!)
Comments