Submission #789217

#TimeUsernameProblemLanguageResultExecution timeMemory
789217ThMinh_Jakarta Skyscrapers (APIO15_skyscraper)C++14
0 / 100
1 ms1036 KiB
#include<bits/stdc++.h> #define forin(i, a, b) for(int i = a; i <= b; ++i) #define ii pair<int, int> using namespace std; const int N = 3e4 + 10; int n, m; int b[N], p[N], d[N]; vector<ii> adj[N]; void dijkstra(int s) { priority_queue<ii, vector<ii>, greater<ii> > pq; fill(d + 1, d + m + 1, 1e18); pq.push({0, s}); d[s] = 0; while(!pq.empty()) { int kc, u; tie(kc, u) = pq.top(); pq.pop(); if(kc != d[u]) continue; for(auto e : adj[u]) { int w, v; tie(w, v) = e; if(d[v] <= d[u] + w) continue; d[v] = d[u] + w; pq.push({d[v], v}); } } } int main () { cin.tie(0)->sync_with_stdio(0); if(fopen("Task.inp","r")) { freopen("Task.inp","r",stdin); freopen("WA.out","w",stdout); } cin>>n>>m; forin(i, 1, m) cin>>b[i]>>p[i]; forin(i, 1, m) forin(j, 1, m) if(i != j) { bool ok = ((b[j] - b[i]) % p[i] == 0); if(ok) { int w = abs(b[j] - b[i]) / p[i]; adj[i].push_back({w, j}); } } dijkstra(1); cout<<d[2]; }

Compilation message (stderr)

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:29:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         freopen("Task.inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
skyscraper.cpp:30:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         freopen("WA.out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#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...