Problems > Tic-Tac-Toe Referee

Tic-Tac-Toe Referee

Difficulty: 1300 2000 ms 128 MB

implementation

Given a tic-tac-toe board (X went first; the position arose from legal play), print the verdict: X or O if that player has three in a row, DRAW for a full board with no winner, ONGOING otherwise.

Input: three lines of three characters (X, O or .).

Output: the verdict.

Constraints:

  • the position is reachable in legal play

Sample Tests

Input 1
XXX
OO.
...
Output 1
X
Input 2
XOX
OXO
OXO
Output 2
DRAW

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.