Internet Problem Solving Contest

IPSC 2005

Solution to Problem A – Alpha Centauri Tennis

This problem was quite tricky. After reading the obscure problem statement, even a convinced tennis (either Alpha-Centauri or Earth) non-player could have smelled a rat.

Of course, the solution was short and easy. The two-player version was identical to Earth tennis (or was a bit simplified). Who can win a match? Only the player, who has won her third set. How could she win the third set? Only by winning the last game of that set. She could have won that game only by winning the last ball of that game. Therefore, the winner of the match is a player, who won the last ball (that's the one who, after knowing that her opponent is unable to return the ball, happily throws her racket to the air). The N player version doesn't offer any other possibility for the winner.

To put it short, the winner of the match is always the same as the winner of the last ball.

Therefore, the most elegant solution was to output the last character of each line in the input.