Sponsored
Use these hints if you're stuck. Try solving on your own first.
Brute force using bitmasks and simulate the rounds.
Calculate each state one time and save its solution.
Solve with full IDE support and test cases