제출 #383354

#제출 시각아이디문제언어결과실행 시간메모리
383354tjrwodnjs999Jakarta Skyscrapers (APIO15_skyscraper)C++11
22 / 100
30 ms3564 KiB
#include <bits/stdc++.h> #define ll long long #define x first #define y second using namespace std; int n,m,B[30005],P[30005]; int dist[30005]; vector<int> Map[30005],adj[30005],vt[100][100]; priority_queue<pair<int,int>> pq; int main() { scanf("%d%d",&n,&m); for(int i=1;i<=m;i++){ scanf("%d%d",&B[i],&P[i]); Map[B[i]].push_back(i); for(int j=1;j<100;j++) vt[j][B[i]%j].push_back(i); } fill(dist,dist+30005,1e9); dist[1]=0; pq.push({0,1}); while(!pq.empty()){ int now=pq.top().second; int cost=-pq.top().first; pq.pop(); if(dist[now]<cost) continue; if(P[now]>=100){ for(int i:Map[B[now]]) if(i!=now){ ll d=abs(B[i]-B[now])/P[now]; if(dist[i]>cost+d) dist[i]=cost+d,pq.push({-dist[i],i}); } for(int j=B[now]+P[now];j<n;j++) for(int i:Map[j]){ ll d=abs(B[i]-B[now])/P[now]; if(dist[i]>cost+d) dist[i]=cost+d,pq.push({-dist[i],i}); } for(int j=B[now]-P[now];j>=0;j--) for(int i:Map[j]){ ll d=abs(B[i]-B[now])/P[now]; if(dist[i]>cost+d) dist[i]=cost+d,pq.push({-dist[i],i}); } } else{ for(int i:vt[P[now]][B[now]%P[now]]){ ll d=abs(B[i]-B[now])/P[now]; if(dist[i]>cost+d) dist[i]=cost+d,pq.push({-dist[i],i}); } } } printf("%d",dist[2]==1e9?-1:dist[2]); return 0; }

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

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