#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for(int i=0; i<n; ++i)
#define pb push_back
#define all(x) x.begin(),x.end()
#define pi pair<int,int>
#define f first
#define s second
const int N=1e5+55;
vector<pi> adj[N];
int ok[N];
int d[N];
int vis[N];
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) {
forn(i,m) {
int u=r[i][0], v=r[i][1], w=l[i];
adj[u].pb({v,w}), adj[v].pb({u,w});
}
priority_queue<pi> q;
forn(i,k) q.push({0,p[i]}), vis[p[i]]=1;
while (q.size()) {
auto it=q.top(); q.pop();
int di=-it.f, u=it.s;
++vis[u];
if (vis[u]!=2) continue;
d[u]=di;
for(auto&e:adj[u]) {
int v=e.f, w=e.s;
q.push({-di-w,v});
}
}
return d[0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2676 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2676 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
3 ms |
3028 KB |
Output is correct |
10 |
Correct |
1 ms |
2644 KB |
Output is correct |
11 |
Correct |
2 ms |
2772 KB |
Output is correct |
12 |
Correct |
6 ms |
3412 KB |
Output is correct |
13 |
Correct |
5 ms |
3412 KB |
Output is correct |
14 |
Correct |
1 ms |
2644 KB |
Output is correct |
15 |
Correct |
2 ms |
2644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2676 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
3 ms |
3028 KB |
Output is correct |
10 |
Correct |
1 ms |
2644 KB |
Output is correct |
11 |
Correct |
2 ms |
2772 KB |
Output is correct |
12 |
Correct |
6 ms |
3412 KB |
Output is correct |
13 |
Correct |
5 ms |
3412 KB |
Output is correct |
14 |
Correct |
1 ms |
2644 KB |
Output is correct |
15 |
Correct |
2 ms |
2644 KB |
Output is correct |
16 |
Correct |
611 ms |
56588 KB |
Output is correct |
17 |
Correct |
62 ms |
10396 KB |
Output is correct |
18 |
Correct |
81 ms |
11812 KB |
Output is correct |
19 |
Correct |
661 ms |
59252 KB |
Output is correct |
20 |
Correct |
482 ms |
53088 KB |
Output is correct |
21 |
Correct |
34 ms |
6212 KB |
Output is correct |
22 |
Correct |
427 ms |
32252 KB |
Output is correct |