제출 #123992

#제출 시각아이디문제언어결과실행 시간메모리
123992AyaBenSaadJakarta Skyscrapers (APIO15_skyscraper)C++14
36 / 100
455 ms262148 KiB
#include <bits/stdc++.h> using namespace std; const int N = 3e4 + 3; //number of skyscrapers const int M = 3e4 + 4; //number of doges; const int inf = 1e9; int n, m, b[M], p[M], ok; vector <pair <int, int> > dgin[N], adj[M]; //int dp[M][N]; long long dis[N]; void Dijkstra (int u) { priority_queue <pair <int, int> > q; dis[u] ++; q.push ({-1, u}); while (q.size()) { int x = q.top().second; q.pop(); for (auto e : adj[x]) { int v = e.first; int c = e.second; if ((!dis[v]) || dis [v] > c + dis[x]){ dis[v] = c + dis[x]; q.push({-dis[v], v}); } } } } int main () { scanf ("%d %d", &n, &m); for (int i = 0; i < m; i++) { scanf("%d %d", &b[i], &p[i]); // dgin[b[i]].push_back (i); int a = b[i], k = 1; while (a-p[i] >= 0) { adj[b[i]].push_back ({a-p[i], k}); k++; a -= p[i]; } a = b[i], k = 1; while (a+p[i] < n) { adj[b[i]].push_back ({a+p[i], k}); k++; a += p[i]; } } /*memset (dp, -1, sizeof dp); int x = solve(0, b[0]); if(ok) printf("%d\n", x-1); else puts("-1");*/ Dijkstra(b[0]); if (dis[b[1]]) printf("%lld\n", dis[b[1]]-1); else puts("-1"); }

컴파일 시 표준 에러 (stderr) 메시지

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:33:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d %d", &n, &m);
     ~~~~~~^~~~~~~~~~~~~~~~~
skyscraper.cpp:35:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &b[i], &p[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...