제출 #330665

#제출 시각아이디문제언어결과실행 시간메모리
330665fammoJakarta Skyscrapers (APIO15_skyscraper)C++11
0 / 100
1096 ms1260 KiB
#pragma GCC optimize("unroll-loops, Ofast") #include <bits/stdc++.h> using namespace std; #define pb push_back //#define int long long const int MAXN = 30000 + 7; int n, m, p[MAXN], b[MAXN], dis[MAXN]; vector<int>adj[MAXN]; inline void dij(int root){ set<pair<int, int>>s; fill(dis, dis + MAXN, INT_MAX/2); dis[root] = 0; s.insert({0, root}); for(int i = 0; i < m; i ++){ auto x = *s.begin(); int v = x.second, d = x.first; s.erase(s.begin()); for(auto p : adj[v]){ int cnt = 1; for(int u = v + p; u < n; u += p){ if(d + cnt < dis[u]){ s.erase({dis[u], u}); dis[u] = d + cnt; s.insert({dis[u], u}); } cnt ++; } cnt = 1; for(int u = v - p; u > -1; u -= p){ if(d + cnt < dis[u]){ s.erase({dis[u], u}); dis[u] = d + cnt; s.insert({dis[u], u}); } cnt ++; } } } return; } int32_t main(){ //ios_base::sync_with_stdio(0), cin.tie(nullptr), cout.tie(nullptr); //cin >> n >> m; scanf("%d %d", &n, &m); for(int i = 0; i < m; i ++){ //cin >> b[i] >> p[i]; scanf("%d %d", b + i, p + i); adj[b[i]].pb(p[i]); } dij(0); printf("%d\n", (dis[1] >= INT_MAX/2? -1ll : dis[1])); return 0; }

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

skyscraper.cpp:1:43: warning: bad option '-f Ofast' to pragma 'optimize' [-Wpragmas]
    1 | #pragma GCC optimize("unroll-loops, Ofast")
      |                                           ^
skyscraper.cpp:10:25: warning: bad option '-f Ofast' to attribute 'optimize' [-Wattributes]
   10 | inline void dij(int root){
      |                         ^
skyscraper.cpp:42:14: warning: bad option '-f Ofast' to attribute 'optimize' [-Wattributes]
   42 | int32_t main(){
      |              ^
skyscraper.cpp: In function 'int32_t main()':
skyscraper.cpp:52:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   52 |     printf("%d\n", (dis[1] >= INT_MAX/2? -1ll : dis[1]));
      |             ~^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |              |                         |
      |              int                       long long int
      |             %lld
skyscraper.cpp:45:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   45 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
skyscraper.cpp:48:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   48 |         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...