USACO Gold 2017 January - Hoof, Paper, Scissors
Author: Neo Wang (C++)
Appears In
Solution
The main observation for this problem is that we only need to keep track of the number of games played , the number of times switched so far , and the current gesture in order to determine the largest number of previous games won for any game .
For every move, either Bessie can either switch or stay on her current gesture. If she changes her gesture, then the next game will have used gestures, which corresponds to the state . We can simulate this for all 3 gestures. Then, we just increment if Bessie wins at game with gesture .
Note that you can just compare the current gesture to H, P, S
because there is always exactly one way to win.
Time Complexity:
Join the USACO Forum!
Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!