This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define wiwihorz
#include "crocodile.h"
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma loop-opt(on)
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define rrep(i, a, b) for(int i = b; i >= a; i --)
#define all(x) x.begin(), x.end()
#define ceil(a, b) ((a + b - 1) / (b))
#define INF 2000000000
#define MOD 1000000007
#define eps (1e-9)
using namespace std;
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())
#ifdef wiwihorz
#define print(a...) cerr << "Line " << __LINE__ << ": ", kout("[" + string(#a) + "] = ", a)
void vprint(auto L, auto R) {while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
void kout() { cerr << endl; }
template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...); }
#else
#define print(...) 0
#define vprint(...) 0
#endif
vector<vector<pii>> mp;
vector<int> a, b;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
mp.assign(N, vector<pii>());
a.assign(N, INF);
b.assign(N, INF);
priority_queue<pii, vector<pii>, greater<pii>> pq;
rep(i, 0, M - 1) {
mp[R[i][0]].push_back({R[i][1], L[i]});
mp[R[i][1]].push_back({R[i][0], L[i]});
}
rep(i, 0, K - 1) {
a[P[i]] = b[P[i]] = 0;
pq.push({0, P[i]});
}
while(pq.size()) {
pii p = pq.top(); pq.pop();
if(b[p.second] != p.first) continue;
int cur = p.second;
for(auto i : mp[cur]) {
int v = min(INF, b[cur] + i.second);
int ori = b[i.first];
if(v < a[i.first]) swap(v, a[i.first]);
if(v < b[i.first]) swap(v, b[i.first]);
if(ori != b[i.first]) pq.push({b[i.first], i.first});
}
}
return b[0];
}
Compilation message (stderr)
crocodile.cpp:5: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
5 | #pragma loop-opt(on)
|
crocodile.cpp:24:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
24 | void vprint(auto L, auto R) {while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
| ^~~~
crocodile.cpp:24:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
24 | void vprint(auto L, auto R) {while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |