Submission #1075773

#TimeUsernameProblemLanguageResultExecution timeMemory
1075773asdasdqwerShortcut (IOI16_shortcut)C++14
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; #include "shortcut.h" #define ll long long #define pii array<ll, 2> ll dijkstra(vector<vector<pii>> &g, int source) { int n=(int)g.size(); vector<ll> dis(n, (int)1e16); dis[source]=0; priority_queue<pii> pq; for (int i=0;i<n;i++) { pq.push({-dis[i], i}); } vector<bool> vis(n, false); while (!pq.empty()) { auto [d, node] = pq.top();pq.pop(); if (vis[node]) continue; vis[node]=true; for (auto [ne, we] : g[node]) { if (dis[node] + we < dis[ne]) { dis[ne] = dis[node] + we; pq.push({-dis[ne], ne}); } } } ll mx =0; for (auto &x:dis) mx=max(mx,x); return mx; } ll diameter(vector<vector<pii>> &g) { ll dis = 0; for (int i=0;i<(int)g.size();i++) { dis = max(dis, dijkstra(g, i)); } return dis; } long long find_shortcut(int n, std::vector <int> l, std::vector <int> d, int c) { int tmp = n; for (int i=0;i<n;i++)if (d[i]) tmp++; vector<vector<pii>> g(tmp); for (int i=0;i<n-1;i++) { g[i].push_back({i+1, (ll)l[i]}); g[i+1].push_back({i, (ll)l[i]}); } int lst = n; for (int i=0;i<n;i++) { if (d[i] == 0) continue; g[i].push_back({lst, (ll)d[i]}); g[lst].push_back({i, (ll)d[i]}); lst++; } ll mxDis = diameter(g); for (int i=0;i<n;i++) { for (int j=i+1;j<n;j++) { g[i].push_back({j, (ll)c}); g[j].push_back({i, (ll)c}); mxDis = min(mxDis, diameter(g)); g[i].pop_back(); g[j].pop_back(); } } return mxDis; }

Compilation message (stderr)

shortcut.cpp: In function 'long long int dijkstra(std::vector<std::vector<std::array<long long int, 2> > >&, int)':
shortcut.cpp:19:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   19 |         auto [d, node] = pq.top();pq.pop();
      |              ^
shortcut.cpp:23:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   23 |         for (auto [ne, we] : g[node]) {
      |                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...