Solution 1
Solution 2 - Generating All Permutations
We can map the games to every possible permutation of the moves (hoof, paper, scissors) and find the sequence which gives us the maximum wins. This works because .
Implementation
Time Complexity:
Python
from itertools import permutationsimport syssys.stdin = open("hps.in", "r")sys.stdout = open("hps.out", "w")n = int(input())games = []games = [list(map(int, input().split())) for _ in range(n)]
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!