Classic
Clean & simple
Crystal
Glassmorphism + Neon
Cyberpunk
Neon glitch art
🚫
违规Action检测
禁止Use右键菜单
⚠️ 此Action已被系统记录
1

Tic Tac Toe

📝 Solutions 🔵 仅限 C++
Problems Description
<img align="right" src="http://plg1.cs.uwaterloo.ca/%7Eacm00/090613/A.png" alt="" /> <p> The game of Tic Tac Toe is played on an </p> <i>n</i> <p> -by- </p> <i>n</i> <p> grid (where </p> <i>n</i> <p> is usually but not necessarily three). Two players alternate placing symbols on squares of the grid. One player places Xes and the other player places Os. The player placing Xes always goes first. When the grid contains a vertical, horizontal, or diagonal sequence of at least </p> <i>m</i> <p> consecutive squares all containing the same symbol, the game ends and the winner is the player who placed the last symbol. When all the squares of the grid are filled, if neither player has won, the game ends in a draw. </p> <p> Your task is to analyze the state of a Tic Tac Toe board, and determine whether the game is still in progress, or if it has completed, who won, or if the game ended in a draw. You should also detect erroneous states of the Tic Tac Toe board that could never occur during an actual game. </p>
Input格式
<p> The first line of input contains the two integers <i>n</i> and <i>m</i>, separated by spaces, with 1 &lt;= <i>m</i> &lt;= <i>n</i> &lt;= 2000. The following <i>n</i> lines of input each contain one row of the Tic Tac Toe board. Each of these lines contains exactly <i>n</i> characters, and each of these characters is either anX, anO, or a period (.), indicating an empty square. </p>
Output格式
<p> Output a single line containing the appropriate stringX WINS,O WINS, orDRAWif the game is over, the stringIN PROGRESSif the game has not yet finished, orERRORif the state of the board could never occur during a game. </p>
Sample
Sample Input 1
3 3 ..X OOX ..X
Sample Output 1
X WINS
Submit Code
请先Login后Submit

🤖 AI 解题助手

OpenRouter
就绪
👋 你好!我是 AI 解题助手。
我已阅读了这problems题,可以帮你points析思路、提供Code示例。
🔓 完全Free · 无需消耗 Token