Submission #394302

#TimeUsernameProblemLanguageResultExecution timeMemory
394302MarcoMeijerCrocodile's Underground City (IOI11_crocodile)C++14
100 / 100
1082 ms88480 KiB
#include "crocodile.h" #include <bits/stdc++.h> using namespace std; // macros typedef long long ll; typedef long double ld; typedef pair<int, int> ii; typedef pair<ll, ll> lll; typedef tuple<int, int, int> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<iii> viii; typedef vector<ll> vll; typedef vector<lll> vlll; #define REP(a,b,c) for(int a=int(b); a<int(c); a++) #define RE(a,c) REP(a,0,c) #define RE1(a,c) REP(a,1,c+1) #define REI(a,b,c) REP(a,b,c+1) #define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--) #define FOR(a,b) for(auto& a : b) #define all(a) a.begin(), a.end() #define INF 1e18 #define EPS 1e-9 #define pb push_back #define popb pop_back #define fi first #define se second #define sz size() int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { // create graph vector<vi > adj; adj .resize(N); vector<vii> adjD; adjD.resize(N); RE(i,M) RE(j,2) adj [R[i][j]].pb(R[i][!j]); RE(i,M) RE(j,2) adjD[R[i][j]].pb({R[i][!j], L[i]}); // initial dijktra vll dist[2]; RE(j,2) dist[j].assign(N, INF); priority_queue<lll,vlll,greater<lll>> pq; RE(i,K) { pq.push({0,P[i]}); pq.push({0,P[i]}); } // dijkstra while(!pq.empty()) { ll d = pq.top().fi; ll u = pq.top().se; pq.pop(); if(dist[1][u] != INF) continue; if(dist[0][u] == INF) { dist[0][u] = d; continue; } else { dist[1][u] = d; } FOR(p,adjD[u]) { ll v = p.fi; if(dist[1][v] != INF) continue; pq.push({d + p.se, v}); } } return dist[1][0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...