#include <bits/stdc++.h>
#include "crocodile.h"
#define DIMN 100010
#define DIMM 1000010
#define INF 2000000000
using namespace std;
priority_queue <pair<int,int>, vector<pair<int,int> >, greater<pair<int,int> > > H;
vector <pair<int,int> > L[DIMN],edg[DIMN];
int f[DIMN],dist[DIMN],viz[DIMN];
pair <int,int> fth[DIMN];
struct idk{
int mini,mini2;
} dp[DIMN];
int travel_plan (int n, int m, int r[][2], int l[], int k, int p[]){
int i;
for (i=0;i<m;i++){
int x = r[i][0]+1, y = r[i][1]+1;
L[x].push_back(make_pair(y,l[i]));
L[y].push_back(make_pair(x,l[i]));
}
for (i=1;i<=n;i++)
dp[i].mini = dp[i].mini2 = INF;
for (i=0;i<k;i++){
int x = p[i] + 1;
f[x] = 1;
H.push(make_pair(0,x));
dp[x].mini = dp[x].mini2 = 0;
}
while (!H.empty()){
int nod = H.top().second;
int cost = H.top().first;
H.pop();
if (cost != dp[nod].mini2)
continue;
for (auto it : L[nod]){
int vecin = it.first, new_cost = it.second;
int aux = dp[vecin].mini2;
if (dp[nod].mini2 + new_cost < dp[vecin].mini){
dp[vecin].mini2 = dp[vecin].mini;
dp[vecin].mini = dp[nod].mini2 + new_cost;
} else {
if (dp[nod].mini2 + new_cost < dp[vecin].mini2)
dp[vecin].mini2 = dp[nod].mini2 + new_cost;
}
if (dp[vecin].mini2 != aux)
H.push(make_pair(dp[vecin].mini2,vecin));
}
}
return dp[1].mini2;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
4992 KB |
Output is correct |
2 |
Correct |
7 ms |
4992 KB |
Output is correct |
3 |
Correct |
8 ms |
5120 KB |
Output is correct |
4 |
Correct |
8 ms |
5120 KB |
Output is correct |
5 |
Correct |
8 ms |
5120 KB |
Output is correct |
6 |
Correct |
10 ms |
5120 KB |
Output is correct |
7 |
Correct |
8 ms |
5120 KB |
Output is correct |
8 |
Correct |
9 ms |
5120 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
4992 KB |
Output is correct |
2 |
Correct |
7 ms |
4992 KB |
Output is correct |
3 |
Correct |
8 ms |
5120 KB |
Output is correct |
4 |
Correct |
8 ms |
5120 KB |
Output is correct |
5 |
Correct |
8 ms |
5120 KB |
Output is correct |
6 |
Correct |
10 ms |
5120 KB |
Output is correct |
7 |
Correct |
8 ms |
5120 KB |
Output is correct |
8 |
Correct |
9 ms |
5120 KB |
Output is correct |
9 |
Correct |
9 ms |
5376 KB |
Output is correct |
10 |
Correct |
7 ms |
5120 KB |
Output is correct |
11 |
Correct |
9 ms |
5120 KB |
Output is correct |
12 |
Correct |
11 ms |
5504 KB |
Output is correct |
13 |
Correct |
11 ms |
5504 KB |
Output is correct |
14 |
Correct |
7 ms |
5120 KB |
Output is correct |
15 |
Correct |
8 ms |
5120 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
4992 KB |
Output is correct |
2 |
Correct |
7 ms |
4992 KB |
Output is correct |
3 |
Correct |
8 ms |
5120 KB |
Output is correct |
4 |
Correct |
8 ms |
5120 KB |
Output is correct |
5 |
Correct |
8 ms |
5120 KB |
Output is correct |
6 |
Correct |
10 ms |
5120 KB |
Output is correct |
7 |
Correct |
8 ms |
5120 KB |
Output is correct |
8 |
Correct |
9 ms |
5120 KB |
Output is correct |
9 |
Correct |
9 ms |
5376 KB |
Output is correct |
10 |
Correct |
7 ms |
5120 KB |
Output is correct |
11 |
Correct |
9 ms |
5120 KB |
Output is correct |
12 |
Correct |
11 ms |
5504 KB |
Output is correct |
13 |
Correct |
11 ms |
5504 KB |
Output is correct |
14 |
Correct |
7 ms |
5120 KB |
Output is correct |
15 |
Correct |
8 ms |
5120 KB |
Output is correct |
16 |
Correct |
532 ms |
43920 KB |
Output is correct |
17 |
Correct |
95 ms |
13432 KB |
Output is correct |
18 |
Correct |
124 ms |
14840 KB |
Output is correct |
19 |
Correct |
659 ms |
47744 KB |
Output is correct |
20 |
Correct |
349 ms |
39416 KB |
Output is correct |
21 |
Correct |
49 ms |
9208 KB |
Output is correct |
22 |
Correct |
363 ms |
34732 KB |
Output is correct |