#include "crocodile.h"
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef pair<int, int> pii;
const int MAX = 101010, INF = 2e9;
int dist[MAX];
bool chk[MAX];
vector<pii> edge[MAX];
priority_queue<pii, vector<pii>, greater<pii>> pq;
pii operator+(const pii &a, const pii &b) {
return pii(a.va + b.va, a.vb + b.vb);
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
for (int i=0; i<M; i++) {
edge[R[i][0]].push_back(pii(L[i], R[i][1]));
edge[R[i][1]].push_back(pii(L[i], R[i][0]));
}
for (int i=0; i<N; i++) dist[i] = INF;
for (int i=0; i<K; i++) {
dist[P[i]] = 0;
for (auto j : edge[P[i]]) pq.push(j);
}
while (!pq.empty()) {
pii tmp = pq.top();
pq.pop();
if (dist[tmp.vb] != INF) continue;
if (!chk[tmp.vb]) {
chk[tmp.vb] = true;
continue;
}
dist[tmp.vb] = tmp.va;
for (auto i : edge[tmp.vb]) pq.push(i+pii(tmp.va, 0));
}
return dist[0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
2680 KB |
Output is correct |
2 |
Correct |
4 ms |
2680 KB |
Output is correct |
3 |
Correct |
4 ms |
2680 KB |
Output is correct |
4 |
Correct |
5 ms |
2808 KB |
Output is correct |
5 |
Correct |
5 ms |
2828 KB |
Output is correct |
6 |
Correct |
5 ms |
2808 KB |
Output is correct |
7 |
Correct |
5 ms |
2808 KB |
Output is correct |
8 |
Correct |
5 ms |
2808 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
2680 KB |
Output is correct |
2 |
Correct |
4 ms |
2680 KB |
Output is correct |
3 |
Correct |
4 ms |
2680 KB |
Output is correct |
4 |
Correct |
5 ms |
2808 KB |
Output is correct |
5 |
Correct |
5 ms |
2828 KB |
Output is correct |
6 |
Correct |
5 ms |
2808 KB |
Output is correct |
7 |
Correct |
5 ms |
2808 KB |
Output is correct |
8 |
Correct |
5 ms |
2808 KB |
Output is correct |
9 |
Correct |
8 ms |
3320 KB |
Output is correct |
10 |
Correct |
4 ms |
2680 KB |
Output is correct |
11 |
Correct |
6 ms |
2808 KB |
Output is correct |
12 |
Correct |
12 ms |
3576 KB |
Output is correct |
13 |
Correct |
10 ms |
3576 KB |
Output is correct |
14 |
Correct |
6 ms |
2744 KB |
Output is correct |
15 |
Correct |
5 ms |
2808 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
2680 KB |
Output is correct |
2 |
Correct |
4 ms |
2680 KB |
Output is correct |
3 |
Correct |
4 ms |
2680 KB |
Output is correct |
4 |
Correct |
5 ms |
2808 KB |
Output is correct |
5 |
Correct |
5 ms |
2828 KB |
Output is correct |
6 |
Correct |
5 ms |
2808 KB |
Output is correct |
7 |
Correct |
5 ms |
2808 KB |
Output is correct |
8 |
Correct |
5 ms |
2808 KB |
Output is correct |
9 |
Correct |
8 ms |
3320 KB |
Output is correct |
10 |
Correct |
4 ms |
2680 KB |
Output is correct |
11 |
Correct |
6 ms |
2808 KB |
Output is correct |
12 |
Correct |
12 ms |
3576 KB |
Output is correct |
13 |
Correct |
10 ms |
3576 KB |
Output is correct |
14 |
Correct |
6 ms |
2744 KB |
Output is correct |
15 |
Correct |
5 ms |
2808 KB |
Output is correct |
16 |
Correct |
1202 ms |
72592 KB |
Output is correct |
17 |
Correct |
115 ms |
13560 KB |
Output is correct |
18 |
Correct |
153 ms |
15016 KB |
Output is correct |
19 |
Correct |
1268 ms |
75472 KB |
Output is correct |
20 |
Correct |
820 ms |
66256 KB |
Output is correct |
21 |
Correct |
62 ms |
7800 KB |
Output is correct |
22 |
Correct |
686 ms |
46584 KB |
Output is correct |