#P1838. Tic Tac Toe Challenge
Tic Tac Toe Challenge
Tic Tac Toe Challenge
Two players, a and uim, are playing Tic Tac Toe on a 3x3 grid. The board positions are numbered as follows:
$$\begin{array}{|c|c|c|}\hline 1 & 2 & 3 \\ \hline 4 & 5 & 6 \\ \hline 7 & 8 & 9 \\ \hline \end{array}$$
Player a always goes first (even though he isn’t very skilled) and uim lets him start. All game records describe finished games – either one of the players has won, or the game ended in a draw. A win is declared if any player manages to mark three cells in a row, column, or diagonal.
Your task is to determine the outcome of a game given the sequence of moves. If player a wins, output a
; if uim wins, output uim
; otherwise, output draw
.
inputFormat
The input consists of a single line containing a sequence of space-separated integers. Each integer (between 1 and 9) represents a move in the order they were played. The game record is complete and ends immediately after a win or when all 9 positions are filled in case of a draw.
outputFormat
Output a single string: a
if player a wins, uim
if player uim wins, or draw
if the game ends in a draw.
sample
1 4 2 5 3
a