#include "crocodile.h"
#include <bits/stdc++.h>
#define range(it, a, b) for (ll it = a; it < b; it++)
#define all(x) begin(x), end(x)
#define ll long long
#define ull unsigned long long
#define uset unordered_set
#define umap unordered_map
using namespace std;
vector<vector<pair<int, int>>> adj;
vector<int> ans;
vector<bool> memo;
int calc (int i) {
if (ans[i] != (1 << 30)) return ans[i];
int mini, smini;
mini = smini = (1 << 30);
for (pair<int, int>& k : adj[i]) {
int x = (1 << 30);
if (!memo[k.first]) x = k.second + calc(k.first);
if (x <= mini) {
smini = mini;
mini = x;
}
else smini = min(x, smini);
}
memo[i] = 1;
return (memo[i] = smini);
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
adj.resize(N);
memo.resize(N);
ans.resize(N, (1 << 30));
range(i, 0, M) {
adj[R[i][0]].push_back({R[i][1], L[i]});
adj[R[i][1]].push_back({R[i][0], L[i]});
}
range(i, 0, K) memo[P[i]] = 0;
return calc(0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
172 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
172 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
172 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |