Skip to content

Commit 48f5f04

Browse files
committed
deploy: fa38c56
1 parent caad0d6 commit 48f5f04

File tree

12 files changed

+8284
-7218
lines changed

12 files changed

+8284
-7218
lines changed

en/lc/3341/index.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77375,9 +77375,9 @@
7737577375
<ul class="md-nav__list">
7737677376

7737777377
<li class="md-nav__item">
77378-
<a href="#solution-1" class="md-nav__link">
77378+
<a href="#solution-1-dijkstras-algorithm" class="md-nav__link">
7737977379
<span class="md-ellipsis">
77380-
Solution 1
77380+
Solution 1: Dijkstra's Algorithm
7738177381
</span>
7738277382
</a>
7738377383

@@ -80147,7 +80147,11 @@ <h2 id="description">Description</h2>
8014780147
<h2 id="solutions">Solutions</h2>
8014880148
<!-- solution:start -->
8014980149

80150-
<h3 id="solution-1">Solution 1</h3>
80150+
<h3 id="solution-1-dijkstras-algorithm">Solution 1: Dijkstra's Algorithm</h3>
80151+
<p>We define a two-dimensional array $\textit{dist}$, where $\textit{dist}[i][j]$ represents the minimum time required to reach room $(i, j)$ from the starting point. Initially, we set all elements in the $\textit{dist}$ array to infinity, and then set the $\textit{dist}$ value of the starting point $(0, 0)$ to $0$.</p>
80152+
<p>We use a priority queue $\textit{pq}$ to store each state, where each state consists of three values $(d, i, j)$, representing the time $d$ required to reach room $(i, j)$ from the starting point. Initially, we add the starting point $(0, 0, 0)$ to $\textit{pq}$.</p>
80153+
<p>In each iteration, we take the front element $(d, i, j)$ from $\textit{pq}$. If $(i, j)$ is the endpoint, we return $d$. If $d$ is greater than $\textit{dist}[i][j]$, we skip this state. Otherwise, we enumerate the four adjacent positions $(x, y)$ of $(i, j)$. If $(x, y)$ is within the map, we calculate the final time $t$ from $(i, j)$ to $(x, y)$ as $t = \max(\textit{moveTime}[x][y], \textit{dist}[i][j]) + 1$. If $t$ is less than $\textit{dist}[x][y]$, we update the value of $\textit{dist}[x][y]$ and add $(t, x, y)$ to $\textit{pq}$.</p>
80154+
<p>The time complexity is $O(n \times m \times \log (n \times m))$, and the space complexity is $O(n \times m)$. Here, $n$ and $m$ are the number of rows and columns of the map, respectively.</p>
8015180155
<div class="tabbed-set tabbed-alternate" data-tabs="1:5"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><input id="__tabbed_1_2" name="__tabbed_1" type="radio" /><input id="__tabbed_1_3" name="__tabbed_1" type="radio" /><input id="__tabbed_1_4" name="__tabbed_1" type="radio" /><input id="__tabbed_1_5" name="__tabbed_1" type="radio" /><div class="tabbed-labels"><label for="__tabbed_1_1">Python3</label><label for="__tabbed_1_2">Java</label><label for="__tabbed_1_3">C++</label><label for="__tabbed_1_4">Go</label><label for="__tabbed_1_5">TypeScript</label></div>
8015280156
<div class="tabbed-content">
8015380157
<div class="tabbed-block">

en/lc/3342/index.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77396,9 +77396,9 @@
7739677396
<ul class="md-nav__list">
7739777397

7739877398
<li class="md-nav__item">
77399-
<a href="#solution-1" class="md-nav__link">
77399+
<a href="#solution-1-dijkstras-algorithm" class="md-nav__link">
7740077400
<span class="md-ellipsis">
77401-
Solution 1
77401+
Solution 1: Dijkstra's Algorithm
7740277402
</span>
7740377403
</a>
7740477404

@@ -80148,7 +80148,11 @@ <h2 id="description">Description</h2>
8014880148
<h2 id="solutions">Solutions</h2>
8014980149
<!-- solution:start -->
8015080150

80151-
<h3 id="solution-1">Solution 1</h3>
80151+
<h3 id="solution-1-dijkstras-algorithm">Solution 1: Dijkstra's Algorithm</h3>
80152+
<p>We define a two-dimensional array $\textit{dist}$, where $\textit{dist}[i][j]$ represents the minimum time required to reach room $(i, j)$ from the starting point. Initially, we set all elements in the $\textit{dist}$ array to infinity, and then set the $\textit{dist}$ value of the starting point $(0, 0)$ to $0$.</p>
80153+
<p>We use a priority queue $\textit{pq}$ to store each state, where each state consists of three values $(d, i, j)$, representing the time $d$ required to reach room $(i, j)$ from the starting point. Initially, we add the starting point $(0, 0, 0)$ to $\textit{pq}$.</p>
80154+
<p>In each iteration, we take the front element $(d, i, j)$ from $\textit{pq}$. If $(i, j)$ is the endpoint, we return $d$. If $d$ is greater than $\textit{dist}[i][j]$, we skip this state. Otherwise, we enumerate the four adjacent positions $(x, y)$ of $(i, j)$. If $(x, y)$ is within the map, we calculate the final time $t$ from $(i, j)$ to $(x, y)$ as $t = \max(\textit{moveTime}[x][y], \textit{dist}[i][j]) + (i + j) \bmod 2 + 1$. If $t$ is less than $\textit{dist}[x][y]$, we update the value of $\textit{dist}[x][y]$ and add $(t, x, y)$ to $\textit{pq}$.</p>
80155+
<p>The time complexity is $O(n \times m \times \log (n \times m))$, and the space complexity is $O(n \times m)$. Here, $n$ and $m$ are the number of rows and columns of the map, respectively.</p>
8015280156
<div class="tabbed-set tabbed-alternate" data-tabs="1:5"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><input id="__tabbed_1_2" name="__tabbed_1" type="radio" /><input id="__tabbed_1_3" name="__tabbed_1" type="radio" /><input id="__tabbed_1_4" name="__tabbed_1" type="radio" /><input id="__tabbed_1_5" name="__tabbed_1" type="radio" /><div class="tabbed-labels"><label for="__tabbed_1_1">Python3</label><label for="__tabbed_1_2">Java</label><label for="__tabbed_1_3">C++</label><label for="__tabbed_1_4">Go</label><label for="__tabbed_1_5">TypeScript</label></div>
8015380157
<div class="tabbed-content">
8015480158
<div class="tabbed-block">

0 commit comments

Comments
 (0)