Submission #852331

#TimeUsernameProblemLanguageResultExecution timeMemory
852331upedCrocodile's Underground City (IOI11_crocodile)C++14
100 / 100
656 ms77828 KiB
#include "crocodile.h" #include <bits/stdc++.h> using namespace std; int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { vector<vector<pair<int, int>>> adj(N); for (int i = 0; i < M; ++i) { adj[R[i][0]].emplace_back(R[i][1], L[i]); adj[R[i][1]].emplace_back(R[i][0], L[i]); } priority_queue<pair<int, int>> pq; vector<pair<int, int>> distance(N, {-1, -1}); vector<bool> is_exit(N); for (int i = 0; i < K; ++i) { is_exit[P[i]] = true; pq.emplace(0, P[i]); distance[P[i]] = {0, 0}; } while (!pq.empty()) { auto [dist, a] = pq.top(); pq.pop(); auto& [min, min2] = distance[a]; if (min == -1 || -dist < min) { min2 = min; min = -dist; } else if (min2 == -1 || -dist < min2) { min2 = -dist; } else if (!is_exit[a]) { continue; } if (min2 == -1) continue; for (auto [b, w] : adj[a]) { if (!is_exit[b]) { pq.emplace((min2 + w) * -1, b); } } } return distance[0].second; }

Compilation message (stderr)

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:22:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   22 |         auto [dist, a] = pq.top(); pq.pop();
      |              ^
crocodile.cpp:23:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   23 |         auto& [min, min2] = distance[a];
      |               ^
crocodile.cpp:33:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   33 |         for (auto [b, w] : adj[a]) {
      |                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...