#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define pll pair<ll, ll>
#define vll vector<ll>
#define vllll vector<vector<ll, ll>>
#define debug(...) cout<<" [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "<<'\n';
typedef long long ll;
const int inf=1e9+5;
const int mxN=1e5+5;
vector<pair<int, int>> adj[mxN];
int dis[mxN];
bool done[mxN];
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
memset(done, 0, sizeof(done));
priority_queue<pair<int, int>> pq;
for(int i=0;i<n;i++){
dis[i]=inf;
}
for(int i=0;i<m;i++){
adj[r[i][0]].pb({r[i][1], l[i]});
adj[r[i][1]].pb({r[i][0], l[i]});
}
for(int i=0;i<k;i++){
dis[p[i]]=0;
pq.push({0, p[i]});
}
while(!pq.empty()){
pair<int, int> cur=pq.top(); pq.pop();
if(dis[cur.S]<inf && cur.F!=0) continue;
if(!done[cur.S] && cur.F!=0){
done[cur.S]=1;
continue;
}
dis[cur.S]=min(-cur.F, dis[cur.S]);
for(auto it:adj[cur.S]){
pq.push({-(-cur.F+it.S), it.F});
}
}
return dis[0];
}
/*test case
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6596 KB |
Output is correct |
2 |
Correct |
2 ms |
6492 KB |
Output is correct |
3 |
Correct |
2 ms |
6492 KB |
Output is correct |
4 |
Correct |
2 ms |
6604 KB |
Output is correct |
5 |
Correct |
2 ms |
6608 KB |
Output is correct |
6 |
Correct |
2 ms |
6744 KB |
Output is correct |
7 |
Correct |
2 ms |
6748 KB |
Output is correct |
8 |
Correct |
2 ms |
6748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6596 KB |
Output is correct |
2 |
Correct |
2 ms |
6492 KB |
Output is correct |
3 |
Correct |
2 ms |
6492 KB |
Output is correct |
4 |
Correct |
2 ms |
6604 KB |
Output is correct |
5 |
Correct |
2 ms |
6608 KB |
Output is correct |
6 |
Correct |
2 ms |
6744 KB |
Output is correct |
7 |
Correct |
2 ms |
6748 KB |
Output is correct |
8 |
Correct |
2 ms |
6748 KB |
Output is correct |
9 |
Correct |
4 ms |
6864 KB |
Output is correct |
10 |
Correct |
1 ms |
6600 KB |
Output is correct |
11 |
Correct |
2 ms |
6612 KB |
Output is correct |
12 |
Correct |
6 ms |
7368 KB |
Output is correct |
13 |
Correct |
6 ms |
7384 KB |
Output is correct |
14 |
Correct |
1 ms |
6596 KB |
Output is correct |
15 |
Correct |
2 ms |
6744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6596 KB |
Output is correct |
2 |
Correct |
2 ms |
6492 KB |
Output is correct |
3 |
Correct |
2 ms |
6492 KB |
Output is correct |
4 |
Correct |
2 ms |
6604 KB |
Output is correct |
5 |
Correct |
2 ms |
6608 KB |
Output is correct |
6 |
Correct |
2 ms |
6744 KB |
Output is correct |
7 |
Correct |
2 ms |
6748 KB |
Output is correct |
8 |
Correct |
2 ms |
6748 KB |
Output is correct |
9 |
Correct |
4 ms |
6864 KB |
Output is correct |
10 |
Correct |
1 ms |
6600 KB |
Output is correct |
11 |
Correct |
2 ms |
6612 KB |
Output is correct |
12 |
Correct |
6 ms |
7368 KB |
Output is correct |
13 |
Correct |
6 ms |
7384 KB |
Output is correct |
14 |
Correct |
1 ms |
6596 KB |
Output is correct |
15 |
Correct |
2 ms |
6744 KB |
Output is correct |
16 |
Correct |
642 ms |
73524 KB |
Output is correct |
17 |
Correct |
63 ms |
16300 KB |
Output is correct |
18 |
Correct |
95 ms |
17580 KB |
Output is correct |
19 |
Correct |
671 ms |
75968 KB |
Output is correct |
20 |
Correct |
470 ms |
68680 KB |
Output is correct |
21 |
Correct |
33 ms |
10332 KB |
Output is correct |
22 |
Correct |
417 ms |
46976 KB |
Output is correct |