이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |