mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
42 lines
3.4 KiB
HTML
42 lines
3.4 KiB
HTML
<p>给你一个下标从 <strong>0</strong> 开始的 <code>8 x 8</code> 网格 <code>board</code> ,其中 <code>board[r][c]</code> 表示游戏棋盘上的格子 <code>(r, c)</code> 。棋盘上空格用 <code>'.'</code> 表示,白色格子用 <code>'W'</code> 表示,黑色格子用 <code>'B'</code> 表示。</p>
|
||
|
||
<p>游戏中每次操作步骤为:选择一个空格子,将它变成你正在执行的颜色(要么白色,要么黑色)。但是,<strong>合法 </strong>操作必须满足:涂色后这个格子是 <strong>好线段的一个端点</strong> (好线段可以是水平的,竖直的或者是对角线)。</p>
|
||
|
||
<p><strong>好线段</strong> 指的是一个包含 <strong>三个或者更多格子(包含端点格子)</strong>的线段,线段两个端点格子为 <strong>同一种颜色</strong> ,且中间剩余格子的颜色都为 <strong>另一种颜色</strong> (线段上不能有任何空格子)。你可以在下图找到好线段的例子:</p>
|
||
<img alt="" src="https://assets.leetcode.com/uploads/2021/07/22/goodlines5.png" style="width: 500px; height: 312px;" />
|
||
<p>给你两个整数 <code>rMove</code> 和 <code>cMove</code> 以及一个字符 <code>color</code> ,表示你正在执行操作的颜色(白或者黑),如果将格子 <code>(rMove, cMove)</code> 变成颜色 <code>color</code> 后,是一个 <strong>合法</strong> 操作,那么返回 <code>true</code> ,如果不是合法操作返回 <code>false</code> 。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<p><img alt="" src="https://assets.leetcode.com/uploads/2021/07/10/grid11.png" style="width: 350px; height: 350px;" /></p>
|
||
|
||
<pre>
|
||
<b>输入:</b>board = [[".",".",".","B",".",".",".","."],[".",".",".","W",".",".",".","."],[".",".",".","W",".",".",".","."],[".",".",".","W",".",".",".","."],["W","B","B",".","W","W","W","B"],[".",".",".","B",".",".",".","."],[".",".",".","B",".",".",".","."],[".",".",".","W",".",".",".","."]], rMove = 4, cMove = 3, color = "B"
|
||
<b>输出:</b>true
|
||
<b>解释:</b>'.','W' 和 'B' 分别用颜色蓝色,白色和黑色表示。格子 (rMove, cMove) 用 'X' 标记。
|
||
以选中格子为端点的两个好线段在上图中用红色矩形标注出来了。
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<p><img alt="" src="https://assets.leetcode.com/uploads/2021/07/10/grid2.png" style="width: 350px; height: 351px;" /></p>
|
||
|
||
<pre>
|
||
<b>输入:</b>board = [[".",".",".",".",".",".",".","."],[".","B",".",".","W",".",".","."],[".",".","W",".",".",".",".","."],[".",".",".","W","B",".",".","."],[".",".",".",".",".",".",".","."],[".",".",".",".","B","W",".","."],[".",".",".",".",".",".","W","."],[".",".",".",".",".",".",".","B"]], rMove = 4, cMove = 4, color = "W"
|
||
<b>输出:</b>false
|
||
<b>解释:</b>虽然选中格子涂色后,棋盘上产生了好线段,但选中格子是作为中间格子,没有产生以选中格子为端点的好线段。
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>board.length == board[r].length == 8</code></li>
|
||
<li><code>0 <= rMove, cMove < 8</code></li>
|
||
<li><code>board[rMove][cMove] == '.'</code></li>
|
||
<li><code>color</code> 要么是 <code>'B'</code> 要么是 <code>'W'</code> 。</li>
|
||
</ul>
|