#P9958. Shell Game Scoring
Shell Game Scoring
Shell Game Scoring
Bessie and Elsie are playing a shell game. Initially, a stone is hidden under one of three shells. Then, several swaps are performed. After each swap, Elsie makes a guess as to the stone's location. Since Elsie does not know the initial position of the stone, your task is to determine the maximum possible number of correct guesses she could achieve if the stone started under any one of the shells.
Each move is described by three integers \(a\), \(b\), and \(g\), where \(a\) and \(b\) are the shells being swapped and \(g\) is Elsie's guess after the swap. When two shells are swapped, if the stone is under one of them, it moves to the other shell.
inputFormat
The first line contains an integer \(n\) (1 ≤ \(n\) ≤ 100) representing the number of moves.
Each of the next \(n\) lines contains three space-separated integers \(a\), \(b\), and \(g\) (1 ≤ \(a, b, g\) ≤ 3):
- \(a\) and \(b\) are the shells that are swapped.
- \(g\) is Elsie's guess of the shell containing the stone after the swap.
outputFormat
Output a single integer: the maximum number of correct guesses Elsie could achieve over all possible initial positions of the stone.
sample
3
1 2 1
3 2 1
1 3 1
2
</p>