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

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
Plain text

خروجی نمونه ۱

X
Plain text

ورودی نمونه ۲

O??
???
???
Plain text

خروجی نمونه ۲

Invalid
Plain text

ورودی نمونه ۳

OOO
??X
XX?
Plain text

خروجی نمونه ۳

O
Plain text

ورودی نمونه ۴

???
???
???
Plain text

خروجی نمونه ۴

Unfinished
Plain text

ورودی نمونه ۵

OXO
XXO
XOX
Plain text

خروجی نمونه ۵

Draw
Plain text

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