using namespace std;
#include <bits/stdc++.h>
#define ll long long
int dp[100001];
int n;
int m, k;
vector<pair<int, int>> adj[100001];
int is[100001];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
for (int i = 0; i < M; i++)
{
adj[R[i][0]].push_back(make_pair(R[i][1], L[i]));
adj[R[i][1]].push_back(make_pair(R[i][0], L[i]));
}
map<int, int> f;
vector<int> d(n + 1, 1e9);
vector<int> visited(n + 1, 0);
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
for (int i = 0; i < K; i++)
{
//is[P[i]] = 1;
q.push({0, P[i]});
visited[P[i]] = 1;
}
while (!q.empty())
{
int u = q.top().second;
int cost = q.top().first;
q.pop();
if (visited[u] == 1)
{
is[u] = 1;
d[u] = cost;
for (int i = 0; i < (int)adj[u].size(); i++)
{
int v = adj[u][i].first;
int cst = adj[u][i].second;
if (!is[v])
q.push(make_pair((cost + cst), v));
}
}
visited[u]++;
}
return d[0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
11 ms |
5356 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
11 ms |
5356 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
11 ms |
5356 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |