mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
52 lines
2.0 KiB
HTML
52 lines
2.0 KiB
HTML
<p>给你一个奇怪的打印机,它有如下两个特殊的打印规则:</p>
|
||
|
||
<ul>
|
||
<li>每一次操作时,打印机会用同一种颜色打印一个矩形的形状,每次打印会覆盖矩形对应格子里原本的颜色。</li>
|
||
<li>一旦矩形根据上面的规则使用了一种颜色,那么 <strong>相同的颜色不能再被使用 </strong>。</li>
|
||
</ul>
|
||
|
||
<p>给你一个初始没有颜色的 <code>m x n</code> 的矩形 <code>targetGrid</code> ,其中 <code>targetGrid[row][col]</code> 是位置 <code>(row, col)</code> 的颜色。</p>
|
||
|
||
<p>如果你能按照上述规则打印出矩形<em> </em><code>targetGrid</code> ,请你返回 <code>true</code> ,否则返回 <code>false</code> 。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<p><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/09/19/sample_1_1929.png" style="height: 138px; width: 483px;"></p>
|
||
|
||
<pre><strong>输入:</strong>targetGrid = [[1,1,1,1],[1,2,2,1],[1,2,2,1],[1,1,1,1]]
|
||
<strong>输出:</strong>true
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<p><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/09/19/sample_2_1929.png" style="height: 290px; width: 483px;"></p>
|
||
|
||
<pre><strong>输入:</strong>targetGrid = [[1,1,1,1],[1,1,3,3],[1,1,3,4],[5,5,1,4]]
|
||
<strong>输出:</strong>true
|
||
</pre>
|
||
|
||
<p><strong>示例 3:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>targetGrid = [[1,2,1],[2,1,2],[1,2,1]]
|
||
<strong>输出:</strong>false
|
||
<strong>解释:</strong>没有办法得到 targetGrid ,因为每一轮操作使用的颜色互不相同。</pre>
|
||
|
||
<p><strong>示例 4:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>targetGrid = [[1,1,1],[3,1,3]]
|
||
<strong>输出:</strong>false
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>m == targetGrid.length</code></li>
|
||
<li><code>n == targetGrid[i].length</code></li>
|
||
<li><code>1 <= m, n <= 60</code></li>
|
||
<li><code>1 <= targetGrid[row][col] <= 60</code></li>
|
||
</ul>
|