Submission #423393

#TimeUsernameProblemLanguageResultExecution timeMemory
423393arayiCrocodile's Underground City (IOI11_crocodile)C++17
100 / 100
952 ms121876 KiB
#include "crocodile.h" #include <vector> #include <queue> #define ad push_back #define lli long long #define MP make_pair #define fr first #define sc second using namespace std; const int N = 1e6 + 30; vector<pair<int, lli> > g[N]; int n; lli col[N]; int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { n = N; for (int i = 0; i < M; i++) { g[R[i][0]].ad(MP(R[i][1], L[i])); g[R[i][1]].ad(MP(R[i][0], L[i])); } for (int i = 0; i < n; i++) col[i] = -2; priority_queue <pair<lli, int> > q; for (int i = 0; i < K; i++) { col[P[i]] = -1; q.push(MP(0, P[i])); } while (!q.empty()) { auto p = q.top(); q.pop(); if (col[p.sc] == -2) { col[p.sc] = -1; } else if (col[p.sc] == -1) { col[p.sc] = -p.fr; for (auto& p1 : g[p.sc]) { if (col[p1.fr] >= 0) continue; q.push(MP(p.fr - p1.sc, p1.fr)); } } } return col[0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...