mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
56 lines
2.3 KiB
HTML
56 lines
2.3 KiB
HTML
<p>给你一个 <code>m * n</code> 的矩阵 <code>seats</code> 表示教室中的座位分布。如果座位是坏的(不可用),就用 <code>'#'</code> 表示;否则,用 <code>'.'</code> 表示。</p>
|
||
|
||
<p>学生可以看到左侧、右侧、左上、右上这四个方向上紧邻他的学生的答卷,但是看不到直接坐在他前面或者后面的学生的答卷。请你计算并返回该考场可以容纳的同时参加考试且无法作弊的 <strong>最大 </strong>学生人数。</p>
|
||
|
||
<p>学生必须坐在状况良好的座位上。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<p><img src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/02/09/image.png" style="height: 197px; width: 339px;" /></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>seats = [["#",".","#","#",".","#"],
|
||
[".","#","#","#","#","."],
|
||
["#",".","#","#",".","#"]]
|
||
<strong>输出:</strong>4
|
||
<strong>解释:</strong>教师可以让 4 个学生坐在可用的座位上,这样他们就无法在考试中作弊。
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>seats = [[".","#"],
|
||
["#","#"],
|
||
["#","."],
|
||
["#","#"],
|
||
[".","#"]]
|
||
<strong>输出:</strong>3
|
||
<strong>解释:</strong>让所有学生坐在可用的座位上。
|
||
</pre>
|
||
|
||
<p><strong>示例 3:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>seats = [["#",".","<strong>.</strong>",".","#"],
|
||
["<strong>.</strong>","#","<strong>.</strong>","#","<strong>.</strong>"],
|
||
["<strong>.</strong>",".","#",".","<strong>.</strong>"],
|
||
["<strong>.</strong>","#","<strong>.</strong>","#","<strong>.</strong>"],
|
||
["#",".","<strong>.</strong>",".","#"]]
|
||
<strong>输出:</strong>10
|
||
<strong>解释:</strong>让学生坐在第 1、3 和 5 列的可用座位上。
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>seats</code> 只包含字符 <code>'.' 和</code><code>'#'</code></li>
|
||
<li><code>m == seats.length</code></li>
|
||
<li><code>n == seats[i].length</code></li>
|
||
<li><code>1 <= m <= 8</code></li>
|
||
<li><code>1 <= n <= 8</code></li>
|
||
</ul>
|