#include "crocodile.h"
#include <bits/stdc++.h>
/// author: LilPluton auuuuuuuuuuuuuuuuuuuuuu
#define OPT ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define intt long long
#define ll long long
#define pb push_back
#define ff first
#define arr array
#define vll vector<int>
#define rep(i,j,k) for(int i = j; i <= k; ++i)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define endll '\n'
using namespace std;
const int INF = 1e9;
const int N = 1e5 + 5;
int travel_plan(int n, int m, int r[][2], int L[], int k, int p[])
{
vector<vector<arr<int,2>>>g(N);
for(int i = 0; i < m; i ++){
g[r[i][0]].push_back({r[i][1], L[i]});
g[r[i][1]].push_back({r[i][0], L[i]});
}
arr<int,2>dist[n];
bool vis[n];
for(int i = 0; i < n; ++i)
dist[i] = {INF,INF}, vis[i] = false;
priority_queue<arr<int,2>>q;
for(int i = 0; i < k; ++i)
{
q.push({0, p[i]});
dist[p[i]] = {0 , 0};
}
while(!q.empty())
{
int v = q.top()[1];
q.pop();
if(vis[v])
continue;
vis[v] = true;
for(auto i : g[v])
{
int u = i[0];
int w = i[1];
if(dist[u][0] > dist[v][1] + w)
{
dist[u][1] = dist[u][0];
dist[u][0] = dist[v][1] + w ;
q.push({dist[u][1], u});
}
else if(dist[u][1] > dist[v][1] + w)
{
dist[u][1] = dist[v][1] + w;
q.push({dist[u][1], u});
}
}
}
return dist[0][1];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |