Skip to content

Commit edb8278

Browse files
committed
Runtime: 1369 ms (Top 10.94%) | Memory: 161.8 MB (Top 51.63%)
1 parent 3460e44 commit edb8278

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

scripts/algorithms/N/Number of Restricted Paths From First to Last Node/Number of Restricted Paths From First to Last Node.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Runtime: 1369 ms (Top 10.94%) | Memory: 161.8 MB (Top 51.63%)
12
typedef pair<int, int> pii;
23
class Solution {
34
public:
@@ -7,13 +8,13 @@ class Solution {
78
gp[edge[0]].push_back({edge[1], edge[2]});
89
gp[edge[1]].push_back({edge[0], edge[2]});
910
}
10-
11+
1112
vector<int> dist(n + 1, INT_MAX);
1213
priority_queue<pii, vector<pii>, greater<pii> > pq;
1314
pq.push({0, n});
1415
dist[n] = 0;
15-
16-
int u, v, w;
16+
17+
int u, v, w;
1718
while (!pq.empty()) {
1819
pii p = pq.top(); pq.pop();
1920
u = p.second;
@@ -28,7 +29,7 @@ class Solution {
2829
vector<int> dp(n + 1, -1);
2930
return dfs(gp, n, dp, dist);
3031
}
31-
32+
3233
int dfs(unordered_map<int, vector<pair<int, int>>>& gp, int s, vector<int>& dp, vector<int>& dist) {
3334
int mod = 1e9+7;
3435
if (s == 1) return 1;
@@ -43,4 +44,4 @@ class Solution {
4344
}
4445
return dp[s] = sum % mod;
4546
}
46-
};
47+
};

0 commit comments

Comments
 (0)