Submission #566180

#TimeUsernameProblemLanguageResultExecution timeMemory
566180ac2huJakarta Skyscrapers (APIO15_skyscraper)C++14
10 / 100
2 ms416 KiB
#include <bits/stdc++.h> #ifdef DEBUG #include "../templates/debug.h" #else #define deb(x...) #endif using namespace std; signed main() { iostream::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr); int n, m;cin >> n >> m; vector<pair<int,int>> doge(m); for(auto &[x,y] : doge)cin >> x >> y; vector<vector<pair<int,int>>> adj(m); for(int i = 0;i<m;i++){ for(int j = 0;j<m;j++){ if(i == j)continue; int ab = abs(doge[i].first - doge[j].first); if(ab%doge[i].second == 0){ adj[i].push_back({j, ab/doge[i].second}); } } } vector<int> dist(n, 1e9); dist[0] = 0; priority_queue<pair<int,int>> pq; pq.push({-dist[0], 0}); while(!pq.empty()){ auto [dd, x] = pq.top(); pq.pop(); dd = -dd; if(dist[x] < dd)continue; for(auto [e, w] : adj[x]){ if(dist[e] > dist[x] + w){ dist[e] = dist[x] + w; pq.push({-dist[e], e}); } } } if(dist[1] == 1e9) cout << -1 << "\n"; else cout << dist[1] << "\n"; }

Compilation message (stderr)

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:13:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   13 |     for(auto &[x,y] : doge)cin >> x >> y;
      |               ^
skyscraper.cpp:29:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   29 |         auto [dd, x] = pq.top();
      |              ^
skyscraper.cpp:33:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   33 |         for(auto [e, w] : adj[x]){
      |                  ^
#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...