제출 #925549

#제출 시각아이디문제언어결과실행 시간메모리
925549panJakarta Skyscrapers (APIO15_skyscraper)C++17
100 / 100
748 ms4408 KiB
#include <bits/stdc++.h> #define mp make_pair #define f first #define s second #define pb push_back #define input(x) scanf("%d", &x); #define print(x, y) printf("%d%c", x, y); using namespace std; typedef int ll; typedef pair<ll, ll> pi; ll const INF = 1e9; vector<ll> adj[30005]; ll where[30005]; int main() { ll n, m, b, p; input(n); input(m); vector<ll> adj[n]; ll where[m]; vector<ll> dist(n, INF); for (ll i=0; i<m; ++i) { input(b); input(p); adj[b].pb(p); where[i] = b; } set<pi> s; dist[where[0]] = 0; s.insert(mp(0, where[0])); while (!s.empty()) { ll c= s.begin()->s; s.erase(s.begin()); for (ll u: adj[c]) { ll jump = 0; for (ll x=c+u; x<n; x+=u) { jump++; if (dist[x]>dist[c]+jump) { if (dist[x]!=INF) s.erase(mp(dist[x], x)); dist[x] = dist[c]+jump; s.insert(mp(dist[x], x)); } } jump = 0; for (ll x=c-u; x>=0; x-=u) { jump++; if (dist[x]>dist[c]+jump) { if (dist[x]!=INF) s.erase(mp(dist[x], x)); dist[x] = dist[c]+jump; s.insert(mp(dist[x], x)); } } } } if (dist[where[1]]==INF) {print(-1, '\n');} else {print(dist[where[1]], '\n');} return 0; }

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

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:6:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define input(x) scanf("%d", &x);
      |                  ~~~~~^~~~~~~~~~
skyscraper.cpp:18:2: note: in expansion of macro 'input'
   18 |  input(n); input(m);
      |  ^~~~~
skyscraper.cpp:6:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define input(x) scanf("%d", &x);
      |                  ~~~~~^~~~~~~~~~
skyscraper.cpp:18:12: note: in expansion of macro 'input'
   18 |  input(n); input(m);
      |            ^~~~~
skyscraper.cpp:6:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define input(x) scanf("%d", &x);
      |                  ~~~~~^~~~~~~~~~
skyscraper.cpp:24:3: note: in expansion of macro 'input'
   24 |   input(b); input(p);
      |   ^~~~~
skyscraper.cpp:6:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define input(x) scanf("%d", &x);
      |                  ~~~~~^~~~~~~~~~
skyscraper.cpp:24:13: note: in expansion of macro 'input'
   24 |   input(b); input(p);
      |             ^~~~~
#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...