• محدودیت زمان: ۱ ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

Every contest needs a judge. You are assigned to judge the Tic-Tac-Toe (aka XO) contest in the SBU. Tic-Tac-Toe judges usually have two major responsibilities. Their responsibilities consist of verifying movements’ correction and declaring the result when the game is over.

In this problem you are going to determine the state of a Tic-Tac-Toe game. Player ‘X’ always plays first and the players play in turns.

ورودی

The input consists of three lines. Each line describes a row by 3 characters. The characters can be X, O, and ?. Character ? denotes an empty cell.

خروجی

  • Print X if player X has won the game in the given input.
  • Print O if player O has won the game in the given input.
  • Print Unfinished if the game is not finished yet.
  • Print Draw, if the game is finished and none of them won the game.
  • Print Invalid if the description is not valid.

مثال‌ها

ورودی نمونه ۱

XOX
OXO
??X

خروجی نمونه ۱

X

ورودی نمونه ۲

O??
???
???

خروجی نمونه ۲

Invalid

ورودی نمونه ۳

OOO
??X
XX?

خروجی نمونه ۳

O

ورودی نمونه ۴

???
???
???

خروجی نمونه ۴

Unfinished

ورودی نمونه ۵

OXO
XXO
XOX

خروجی نمونه ۵

Draw
ارسال پاسخ برای این سؤال
فایلی انتخاب نشده است.