//Dost SEFEROĞLU
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
#define int long long
#define ii int32_t
#define pii pair<int,int>
#define ff first
#define ss second
#define sp << " " <<
#define all(cont) cont.begin(),cont.end()
#define vi vector<int>
const int inf = 2e9;
ii travel_plan(ii N, ii M, ii R[][2], ii L[], ii K, ii P[])
{
vector<pii> edges[N];
for (int i=0;i<M;i++) {
edges[R[i][0]].push_back({R[i][1],L[i]});
edges[R[i][1]].push_back({R[i][0],L[i]});
}
vi cnt(N,0);
vi dist(N,inf);
priority_queue<pii,vector<pii>,greater<pii>> pq;
for (int i=0;i<K;i++) {
dist[P[i]] = 0;
cnt[P[i]] = 1;
pq.push({0,P[i]});
}
while (!pq.empty()) {
pii f = pq.top();
pq.pop();
cnt[f.ss]++;
if (cnt[f.ss] != 2) continue;
dist[f.ss] = f.ff;
for (auto& [go,w] : edges[f.ss]) {
pq.push({f.ff+w,go});
}
}
return dist[0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4536 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
2 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4536 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
2 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
3 ms |
5212 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
2 ms |
4700 KB |
Output is correct |
12 |
Correct |
5 ms |
5600 KB |
Output is correct |
13 |
Correct |
4 ms |
5860 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
2 ms |
4696 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4536 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
2 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
3 ms |
5212 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
2 ms |
4700 KB |
Output is correct |
12 |
Correct |
5 ms |
5600 KB |
Output is correct |
13 |
Correct |
4 ms |
5860 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
2 ms |
4696 KB |
Output is correct |
16 |
Correct |
647 ms |
112888 KB |
Output is correct |
17 |
Correct |
71 ms |
19284 KB |
Output is correct |
18 |
Correct |
91 ms |
21840 KB |
Output is correct |
19 |
Correct |
671 ms |
118428 KB |
Output is correct |
20 |
Correct |
523 ms |
99320 KB |
Output is correct |
21 |
Correct |
36 ms |
9780 KB |
Output is correct |
22 |
Correct |
482 ms |
63760 KB |
Output is correct |