Submission #254638

#TimeUsernameProblemLanguageResultExecution timeMemory
254638SortingCrocodile's Underground City (IOI11_crocodile)C++14
100 / 100
639 ms48388 KiB
//#include "crocodile.h" #include <bits/stdc++.h> using namespace std; const int k_N = 1e5 + 3; const int k_Inf = 1e9 + 7; int n, m, k; vector<pair<int, int>> adj[k_N]; bool e[k_N]; pair<int, int> d[k_N]; void dijkstra(){ priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq; for(int i = 0; i < n; ++i){ if(e[i]){ d[i] = {0, 0}; pq.push({0, i}); } else d[i] = {k_Inf, k_Inf}; } while(!pq.empty()){ auto [dist, u] = pq.top(); pq.pop(); if(dist != d[u].second) continue; for(auto [to, c]: adj[u]){ int new_d = c + dist; if(d[to].second > new_d){ int pr = d[to].second; d[to].second = new_d; if(d[to].first > d[to].second) swap(d[to].first, d[to].second); if(d[to].second != pr) pq.push({d[to].second, to}); } } } } 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 < m; ++i){ adj[R[i][0]].push_back({R[i][1], L[i]}); adj[R[i][1]].push_back({R[i][0], L[i]}); } for(int i = 0; i < k; ++i) e[P[i]] = true; dijkstra(); return d[0].second; } /* 5 4 3 0 1 2 0 2 3 3 2 1 2 4 4 1 3 4 7 */ /* 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 14 */

Compilation message (stderr)

crocodile.cpp: In function 'void dijkstra()':
crocodile.cpp:28:14: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
         auto [dist, u] = pq.top();
              ^
crocodile.cpp:33:18: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
         for(auto [to, c]: adj[u]){
                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...