经典简约
清爽简洁,回归本真
液态水晶
毛玻璃+霓虹光带
赛博朋克
霓虹故障艺术风
🚫
违规操作检测
禁止使用右键菜单
⚠️ 此操作已被系统记录
1

Tic Tac Toe

📝 题解 🔵 仅限 C++
题目描述
<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>
输入格式
<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>
输出格式
<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>
样例
样例输入 1
3 3 ..X OOX ..X
样例输出 1
X WINS
提交代码
请先登录后提交

🤖 AI 解题助手

DeepSeek
就绪
👋 你好!我是 AI 解题助手。
我已阅读了这道题,可以帮你分析思路、提供代码示例。
⚠️ 请先登录后使用