This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//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]});
}
vi cnt(N,0);
vi dist(N,inf);
priority_queue<pii,vector<pii>,greater<pii>> pq;
for (int i=0;i<K;i++) {
dist[P[i]] = 0;
cnt[P[i]] = 1;
pq.push({0,P[i]});
}
while (!pq.empty()) {
pii f = pq.top();
pq.pop();
cnt[f.ss]++;
if (cnt[f.ss] != 2) continue;
dist[f.ss] = f.ff;
for (auto& [go,w] : edges[f.ss]) {
pq.push({f.ff+w,go});
}
}
return dist[0];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |