Tic-Tac-Toe Solver
시간 제한1초메모리 제한2048 MB
3x3 틱택토 판을 읽고 X가 이겼는지, O가 이겼는지, 아니면 아무도 이기지 못했는지 판정한다.
문제
After years of planning, you're finally ready to host the Tic-Tac-Toe world championships. Everything had been going great until you made a terrible discovery: the judges, who determine which player has won the game, have been taking bribes! There's not enough time to train new ones, so you opt for a backup plan: you'll create a piece of code that analyzes the board and tells the players if anyone has won.
A Tic-Tac-Toe board looks like the following. Every square can be empty, filled with an X, or filled with a O (capital letter 'o').
Player X has won if they have three X's in a row. Player O wins if they can do the same with the O's. A row can be horizontal, vertical, or diagonal.
Can you write the new judging code and salvage the competition?
입력
The input consists of three lines each with characters. Each line represents a row on the board. Each character in a line represents a column. This means you have rows and columns just like a normal Tic-Tac-Toe board.
Each square in the board contains either an X, O (that's a capital letter, not a number), or E. X and O represent markings made by the players while E represents an empty square.
출력
If player X has won, you should print out the character X. If player O has won, you should print out the character O. If neither player has won, you should print out the character N.