1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/逃离大迷宫 [escape-a-large-maze].html
2022-03-29 12:43:11 +08:00

43 lines
2.1 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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>在一个 10<sup>6</sup> x 10<sup>6</sup> 的网格中,每个网格上方格的坐标为 <code>(x, y)</code></p>
<p>现在从源方格 <code>source = [s<sub>x</sub>, s<sub>y</sub>]</code> 开始出发,意图赶往目标方格 <code>target = [t<sub>x</sub>, t<sub>y</sub>]</code> 。数组 <code>blocked</code> 是封锁的方格列表,其中每个 <code>blocked[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> 表示坐标为 <code>(x<sub>i</sub>, y<sub>i</sub>)</code> 的方格是禁止通行的。</p>
<p>每次移动,都可以走到网格中在四个方向上相邻的方格,只要该方格 <strong></strong> 在给出的封锁列表 <code>blocked</code> 上。同时,不允许走出网格。</p>
<p>只有在可以通过一系列的移动从源方格 <code>source</code> 到达目标方格 <code>target</code> 时才返回 <code>true</code>。否则,返回 <code>false</code></p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>blocked = [[0,1],[1,0]], source = [0,0], target = [0,2]
<strong>输出:</strong>false
<strong>解释:</strong>
从源方格无法到达目标方格,因为我们无法在网格中移动。
无法向北或者向东移动是因为方格禁止通行。
无法向南或者向西移动是因为不能走出网格。</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>blocked = [], source = [0,0], target = [999999,999999]
<strong>输出:</strong>true
<strong>解释:</strong>
因为没有方格被封锁,所以一定可以到达目标方格。
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>0 <= blocked.length <= 200</code></li>
<li><code>blocked[i].length == 2</code></li>
<li><code>0 <= x<sub>i</sub>, y<sub>i</sub> < 10<sup>6</sup></code></li>
<li><code>source.length == target.length == 2</code></li>
<li><code>0 <= s<sub>x</sub>, s<sub>y</sub>, t<sub>x</sub>, t<sub>y</sub> < 10<sup>6</sup></code></li>
<li><code>source != target</code></li>
<li>题目数据保证 <code>source</code><code>target</code> 不在封锁列表内</li>
</ul>