Submission #398429

#TimeUsernameProblemLanguageResultExecution timeMemory
398429AugustinasJucasCrocodile's Underground City (IOI11_crocodile)C++14
100 / 100
585 ms62140 KiB
#include "crocodile.h" #include <bits/stdc++.h> using namespace std; const int dydis = 1e5 + 10; const long long inf = 1e18; vector<pair<int, int> > gr[dydis]; int n, m, k; pair<long long, long long> dist[dydis]; int kek[dydis]; bool don[dydis]; int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){ n = N; m = M; k = K; for(int i = 0; i < n; i++) dist[i] = {inf, inf}; for(int i = 0; i < M; i++) { gr[R[i][0]].push_back({R[i][1], L[i]}); gr[R[i][1]].push_back({R[i][0], L[i]}); } priority_queue<pair<int, int> > q; for(int i = 0; i < k; i++){ q.push({0, P[i]}); } while(q.size()){ int v = q.top().second; long long dst = -q.top().first; q.pop(); if(don[v]) continue; if(dst != 0 && (dst == inf || dst != dist[v].second)) continue; don[v] = 1; for(auto x : gr[v]){ long long gal = x.second + dst; if(gal < dist[x.first].first){ dist[x.first].second = dist[x.first].first; dist[x.first].first = gal; q.push({-dist[x.first].second, x.first}); }else if(gal < dist[x.first].second){ dist[x.first].second = gal; q.push({-dist[x.first].second, x.first}); } } } return dist[0].second; } /* 5 4 3 0 1 2 0 2 3 3 2 1 2 4 4 1 3 4 5 7 2 0 2 4 0 3 3 3 2 2 2 1 10 0 1 100 0 4 7 3 4 9 1 3 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...