제출 #396685

#제출 시각아이디문제언어결과실행 시간메모리
396685leinad2Jakarta Skyscrapers (APIO15_skyscraper)C++17
22 / 100
953 ms78536 KiB
#include<bits/stdc++.h> using namespace std; int n, m, i, j, k, A[30010], a, b, w, s, e; vector<pair<int, int> >adj[30010]; priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > >pq; main() { ios_base::sync_with_stdio(!cin.tie(NULL)); for(cin>>n>>m;i++<m;) { cin>>a>>b;if(i==1)s=a;if(i==2)e=a; for(j=a+b;j<=n;j+=b)adj[a].push_back({j, (j-a)/b}); for(j=a-b;j>0;j-=b)adj[a].push_back({j, (a-j)/b}); } for(i=0;i<n;i++)A[i]=1e9; pq.push({0, s}); while(pq.size()) { pair<int, int>p=pq.top();pq.pop(); a=p.second;b=p.first; if(A[a]<1e9)continue; A[a]=b; for(i=0;i<adj[a].size();i++) { pq.push({A[a]+adj[a][i].second, adj[a][i].first}); } } if(A[e]==1e9)A[e]=-1;cout<<A[e]; }

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

skyscraper.cpp:6:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      |      ^
skyscraper.cpp: In function 'int main()':
skyscraper.cpp:23:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         for(i=0;i<adj[a].size();i++)
      |                 ~^~~~~~~~~~~~~~
skyscraper.cpp:28:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   28 |     if(A[e]==1e9)A[e]=-1;cout<<A[e];
      |     ^~
skyscraper.cpp:28:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   28 |     if(A[e]==1e9)A[e]=-1;cout<<A[e];
      |                          ^~~~
#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...