Submission #148277

#TimeUsernameProblemLanguageResultExecution timeMemory
148277karmaCrocodile's Underground City (IOI11_crocodile)C++14
89 / 100
748 ms39312 KiB
#include <bits/stdc++.h> #include "crocodile.h" #define ll long long #define pb emplace_back #define mp make_pair #define fi first #define se second using namespace std; const int N = int(1e5) + 2; const ll oo = (ll)(1e15) + 7; typedef pair<ll, ll> pii; pii top, d[N]; vector<int> a[N]; int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) { priority_queue<pii, vector<pii>, greater<pii>> pq; fill(d, d + n, mp(oo, oo)); for(int i = 0; i < m; ++i) a[r[i][0]].pb(i), a[r[i][1]].pb(i); for(int i = 0; i < k; ++i) d[p[i]] = mp(0, 0), pq.push(mp(0, p[i])); ll v, dis; while(!pq.empty()) { top = pq.top(); pq.pop(); if(d[top.se].se != top.fi) continue; for(int i: a[top.se]) { v = top.se ^ r[i][0] ^ r[i][1]; dis = d[top.se].se + l[i]; if(d[v].fi > dis) d[v] = mp(dis, d[v].fi); else if(d[v].se > dis) d[v] = mp(d[v].fi, dis); else continue; pq.push(mp(d[v].se, v)); } } return d[0].se; } // //int n, m, r[N][2], l[N], k, p[N]; // //int main() //{ // ios_base::sync_with_stdio(0); // cin.tie(0), cout.tie(0); // if(fopen("test.inp", "r")) { // freopen("test.inp", "r", stdin); // freopen("test.out", "w", stdout); // } // cin >> n >> m >> k; // for(int i = 0; i < m; ++i) cin >> r[i][0] >> r[i][1] >> l[i]; // for(int i = 0; i < k; ++i) cin >> p[i]; // cout << travel_plan(n, m, r, l, k, p); //}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...