Submission #124235

#TimeUsernameProblemLanguageResultExecution timeMemory
124235elabensaadJakarta Skyscrapers (APIO15_skyscraper)C++14
36 / 100
492 ms262144 KiB
#include <bits/stdc++.h> using namespace std; int n, m, x, y, vis[30005], p[30005], pos, sta; vector <pair <int , int> > t[30005]; void DJ(int u){ priority_queue <pair <int, int> >q; vis[u] = 1; q.push({-1, u}); while(!q.empty()){ int l = q.top().second; q.pop(); for(int i = 0;i < t[l].size();i++){ int nc = vis[l]+t[l][i].second; if(vis[t[l][i].first] == 0 || nc < vis[t[l][i].first]){ vis[t[l][i].first] = nc; q.push({-nc, t[l][i].first}); } } } } int main () { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for(int i = 0;i < m;i++){ cin >> x >> p[i]; int c = x; if(i == 0)sta = x; if(i == 1)pos = x; int k = x; //t[i].push_back({x, 0}); int cur = 0; while(x+p[i] < n){ x+=p[i]; cur++; t[c].push_back({x, cur}); } cur = 0; while(k-p[i] >= 0){ k-=p[i]; cur++; t[c].push_back({k, cur}); } } DJ(sta); if(vis[pos] == 0)cout << -1; else cout << vis[pos]-1 ; }

Compilation message (stderr)

skyscraper.cpp: In function 'void DJ(int)':
skyscraper.cpp:15:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 0;i < t[l].size();i++){
                       ~~^~~~~~~~~~~~~
#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...