//Dost SEFEROĞLU
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
#define int long long
#define ii int32_t
#define pii pair<int,int>
#define ff first
#define ss second
#define sp << " " <<
#define all(cont) cont.begin(),cont.end()
#define vi vector<int>
const int inf = 2e9;
ii travel_plan(ii N, ii M, ii R[][2], ii L[], ii K, ii P[])
{
vector<pii> edges[N];
for (int i=0;i<M;i++) {
edges[R[i][0]].push_back({R[i][1],L[i]});
edges[R[i][1]].push_back({R[i][0],L[i]});
}
pii dist[N];
for (int i=0;i<N;i++) dist[i] = {inf,inf};
using state = pair<pii,int>;
priority_queue<state,vector<state>,greater<state>> pq;
for (int i=0;i<K;i++) {
dist[P[i]] = {0,0};
pq.push({{0,0},P[i]});
}
while (!pq.empty()) {
state f = pq.top();
pq.pop();
if (pii{f.ff.ss,f.ff.ff} > pii{dist[f.ss].ss,dist[f.ss].ff}) continue;
cout << f.ff.ff sp f.ff.ss sp f.ss << endl;
for (auto it : edges[f.ss]) {
int go = it.ff,w = it.ss;
pii pp = {dist[go].ff,w+f.ff.ss};
if (pp.ff > pp.ss) swap(pp.ff,pp.ss);
if (dist[go].ss > pp.ss || (dist[go].ss == pp.ss && dist[go].ff > pp.ff)) {
dist[go] = pp;
state pusher = make_pair(pp,go);
pq.push(pusher);
}
}
}
return dist[0].ss;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |