Editorial for COCI '06 Contest 5 #3 Tenis
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
The rules are seemingly simple, but checking if a result could have been achieved according to the results is less so. If any of the following applies, the result is not legal:
- Players won the same number of games in a set
- A player won a set with less than 6 games
- A player won a set by a difference of only one game (except 7:6 in the first two sets), or more than two games if he won 7
- The player won more than 7 games in the first or second set
- The result is 1:0, 1:1, 3:0 (sets), or more than 3 sets have been played
- Federer lost a set
An alternative solution is to generate all legal results according to the rules and check for each match if it's among the valid results.
Comments