Submission #566181

#TimeUsernameProblemLanguageResultExecution timeMemory
566181ac2huJakarta Skyscrapers (APIO15_skyscraper)C++14
10 / 100
2 ms340 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; if(doge[i].second == 0)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:30:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   30 |         auto [dd, x] = pq.top();
      |              ^
skyscraper.cpp:34:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   34 |         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...