#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define ss second
#define ff first
typedef long long ll;
// #define int ll
int mod = 1e9+7;
int travel_plan(int N, int M, int R[][2],
int L[], int k, int p[]){
int n = N, m = M;
vector<vector<pair<int,int>>> adj(n);
for(int i = 0; i < m; ++i){
int a = R[i][0],b = R[i][1],c = L[i];
adj[a].push_back({b,c});
adj[b].push_back({a,c});
}
set<int> exit;
for(int i = 0; i < k; ++i){
exit.insert(p[i]);
}
priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>>> pq;
vector<ll> dis(n, 1e18);
int ans = 1e9;
dis[0] = 0;
pq.push({0,0});
bool pass = 0;
while(!pq.empty()){
pair<int,int> a = pq.top(); pq.pop();
if(dis[a.ss]!=a.ff){
continue;
}
if(exit.find(a.ss)!=exit.end()){
ans = min(ans, a.ff);
}
pass = false;
for(auto &[nxt, w] : adj[a.ss]){
if(a.ff+w<nxt&&pass){
pq.push({a.ff+w,nxt});
break;
}
pass = true;
}
}
return ans;
}
// signed main(){
// ios_base::sync_with_stdio(false);
// cin.tie(NULL);
// // ifstream cin ("shortcut.in");
// // ofstream cout ("shortcut.out");
// return 0;
// }
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |