1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/用邮票贴满网格图 [stamping-the-grid].html
2022-03-29 12:43:11 +08:00

48 lines
2.2 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个&nbsp;<code>m x n</code>&nbsp;的二进制矩阵&nbsp;<code>grid</code>&nbsp;,每个格子要么为&nbsp;<code>0</code>&nbsp;(空)要么为&nbsp;<code>1</code>&nbsp;(被占据)。</p>
<p>给你邮票的尺寸为&nbsp;<code>stampHeight x stampWidth</code>&nbsp;。我们想将邮票贴进二进制矩阵中,且满足以下&nbsp;<strong>限制</strong>&nbsp;&nbsp;<strong>要求</strong>&nbsp;</p>
<ol>
<li>覆盖所有 <strong></strong>&nbsp;格子。</li>
<li>不覆盖任何 <strong>被占据&nbsp;</strong>的格子。</li>
<li>我们可以放入任意数目的邮票。</li>
<li>邮票可以相互有 <strong>重叠</strong>&nbsp;部分。</li>
<li>邮票不允许 <strong>旋转</strong>&nbsp;</li>
<li>邮票必须完全在矩阵 <strong></strong>&nbsp;</li>
</ol>
<p>如果在满足上述要求的前提下,可以放入邮票,请返回&nbsp;<code>true</code>&nbsp;,否则返回<i>&nbsp;</i><code>false</code>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2021/11/03/ex1.png" style="width: 180px; height: 237px;"></p>
<pre><b>输入:</b>grid = [[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0]], stampHeight = 4, stampWidth = 3
<b>输出:</b>true
<b>解释:</b>我们放入两个有重叠部分的邮票(图中标号为 1 和 2它们能覆盖所有与空格子。
</pre>
<p><strong>示例 2</strong></p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2021/11/03/ex2.png" style="width: 170px; height: 179px;"></p>
<pre><b>输入:</b>grid = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]], stampHeight = 2, stampWidth = 2
<b>输出:</b>false
<b>解释:</b>没办法放入邮票覆盖所有的空格子,且邮票不超出网格图以外。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>m == grid.length</code></li>
<li><code>n == grid[r].length</code></li>
<li><code>1 &lt;= m, n &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= m * n &lt;= 2 * 10<sup>5</sup></code></li>
<li><code>grid[r][c]</code> 要么是&nbsp;<code>0</code>&nbsp;,要么是&nbsp;<code>1</code></li>
<li><code>1 &lt;= stampHeight, stampWidth &lt;= 10<sup>5</sup></code></li>
</ul>