#include "crocodile.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define nmax 100008
const long long inf = 1e18;
using namespace std;
typedef pair<long long, long long> pii;
pii operator+(pii x, long long y){
return (y <= x.fi) ? make_pair(y, x.fi) : ((y < x.se) ? make_pair(x.fi, y) : x);
}
int n, m;
bool kt[nmax];
pii f[nmax];
vector<pii> l[nmax];
priority_queue<pii, vector<pii>, greater<pii> > s;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
n = N;
m = M;
fill(f, f + n + 1, make_pair(inf, inf));
fill(kt, kt + n + 1, false);
for (int i = 0; i < n; i++){
int u = R[i][0], v = R[i][1], w = L[i];
l[u].push_back({v, w});
l[v].push_back({u, w});
}
for (int i = 0; i < K; i++)
f[P[i]] = {0, 0};
while (!kt[0]){
int sp = -1;
for (int i = 0; i <= n; i++)
if (kt[i] || f[i].se == inf)
continue;
else{
if (sp == -1 || f[i].se < f[sp].se)
sp = i;
}
if (sp == -1)
break;
kt[sp] = true;
for (pii it : l[sp]){
if (kt[it.fi])
continue;
f[it.fi] = f[it.fi] + (f[sp].se + it.se);
}
}
return f[0].se;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
3 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
4 ms |
2824 KB |
Output is correct |
5 |
Correct |
4 ms |
2644 KB |
Output is correct |
6 |
Correct |
3 ms |
2644 KB |
Output is correct |
7 |
Correct |
3 ms |
2644 KB |
Output is correct |
8 |
Correct |
3 ms |
2644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
3 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
4 ms |
2824 KB |
Output is correct |
5 |
Correct |
4 ms |
2644 KB |
Output is correct |
6 |
Correct |
3 ms |
2644 KB |
Output is correct |
7 |
Correct |
3 ms |
2644 KB |
Output is correct |
8 |
Correct |
3 ms |
2644 KB |
Output is correct |
9 |
Incorrect |
2 ms |
2644 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
3 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
4 ms |
2824 KB |
Output is correct |
5 |
Correct |
4 ms |
2644 KB |
Output is correct |
6 |
Correct |
3 ms |
2644 KB |
Output is correct |
7 |
Correct |
3 ms |
2644 KB |
Output is correct |
8 |
Correct |
3 ms |
2644 KB |
Output is correct |
9 |
Incorrect |
2 ms |
2644 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |