#pragma GCC optimize("O3")
#include "crocodile.h"
#include <bits/stdc++.h>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
const ll INF = 1e17 + 7;
const int MAXN = 1e5 + 5;
ll dist[MAXN];
vector<pair<int,ll>> adj[MAXN];
priority_queue<ll> mx[MAXN];
int vis[MAXN][2];
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) {
for (int i = 0; i < m; i++) {
int u = r[i][0], v = r[i][1];
adj[u].pb({v, l[i]});
adj[v].pb({u, l[i]});
}
fill(dist, dist + MAXN, INF);
priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> pq;
for (int i = 0; i < k; i++)
pq.push({0, p[i]}), dist[p[i]] = 0, vis[p[i]][0] = 1;
while (!pq.empty()) {
pair<ll,int> cur = pq.top(); pq.pop();
if (!vis[cur.se][0]) {
vis[cur.se][0] = 1;
continue;
}
if (vis[cur.se][1])
continue;
vis[cur.se][1] = 1;
if (cur.se == 0)
return cur.fi;
for (pair<int,ll> nx: adj[cur.se]) {
if (vis[nx.fi][1])
continue;
pq.push({cur.fi + nx.se, nx.fi});
}
}
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
6656 KB |
Output is correct |
2 |
Correct |
10 ms |
6656 KB |
Output is correct |
3 |
Correct |
9 ms |
6656 KB |
Output is correct |
4 |
Correct |
11 ms |
6784 KB |
Output is correct |
5 |
Correct |
9 ms |
6784 KB |
Output is correct |
6 |
Correct |
10 ms |
6656 KB |
Output is correct |
7 |
Correct |
11 ms |
6784 KB |
Output is correct |
8 |
Correct |
12 ms |
6756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
6656 KB |
Output is correct |
2 |
Correct |
10 ms |
6656 KB |
Output is correct |
3 |
Correct |
9 ms |
6656 KB |
Output is correct |
4 |
Correct |
11 ms |
6784 KB |
Output is correct |
5 |
Correct |
9 ms |
6784 KB |
Output is correct |
6 |
Correct |
10 ms |
6656 KB |
Output is correct |
7 |
Correct |
11 ms |
6784 KB |
Output is correct |
8 |
Correct |
12 ms |
6756 KB |
Output is correct |
9 |
Correct |
20 ms |
7292 KB |
Output is correct |
10 |
Correct |
10 ms |
6656 KB |
Output is correct |
11 |
Correct |
11 ms |
6756 KB |
Output is correct |
12 |
Correct |
14 ms |
7680 KB |
Output is correct |
13 |
Correct |
16 ms |
7424 KB |
Output is correct |
14 |
Correct |
10 ms |
6656 KB |
Output is correct |
15 |
Correct |
11 ms |
6784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
6656 KB |
Output is correct |
2 |
Correct |
10 ms |
6656 KB |
Output is correct |
3 |
Correct |
9 ms |
6656 KB |
Output is correct |
4 |
Correct |
11 ms |
6784 KB |
Output is correct |
5 |
Correct |
9 ms |
6784 KB |
Output is correct |
6 |
Correct |
10 ms |
6656 KB |
Output is correct |
7 |
Correct |
11 ms |
6784 KB |
Output is correct |
8 |
Correct |
12 ms |
6756 KB |
Output is correct |
9 |
Correct |
20 ms |
7292 KB |
Output is correct |
10 |
Correct |
10 ms |
6656 KB |
Output is correct |
11 |
Correct |
11 ms |
6756 KB |
Output is correct |
12 |
Correct |
14 ms |
7680 KB |
Output is correct |
13 |
Correct |
16 ms |
7424 KB |
Output is correct |
14 |
Correct |
10 ms |
6656 KB |
Output is correct |
15 |
Correct |
11 ms |
6784 KB |
Output is correct |
16 |
Correct |
934 ms |
100668 KB |
Output is correct |
17 |
Correct |
117 ms |
20856 KB |
Output is correct |
18 |
Correct |
140 ms |
23288 KB |
Output is correct |
19 |
Correct |
1126 ms |
104668 KB |
Output is correct |
20 |
Correct |
504 ms |
71544 KB |
Output is correct |
21 |
Correct |
80 ms |
13560 KB |
Output is correct |
22 |
Correct |
660 ms |
68380 KB |
Output is correct |