제출 #236048

#제출 시각아이디문제언어결과실행 시간메모리
236048thtsshz_bgwrswhJakarta Skyscrapers (APIO15_skyscraper)C++17
0 / 100
5 ms1024 KiB
#pragma GCC optimize("Ofast") #include<stdio.h> #include<vector> #include<queue> #include<set> #include<utility> #include<algorithm> using namespace std; int pos[30005],power[30005],dis[30005]; vector<pair<int,int>> g[30005]; priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq; int main(){ int i,j,n,m; scanf("%d%d",&n,&m); for(i=0;i<m;i++) scanf("%d%d",&pos[i],&power[i]); for(i=0;i<m;i++) for(j=0;j<m;j++){ if(j==i||pos[j]==pos[i]||abs(pos[j]-pos[i])%power[i]) continue; g[i].emplace_back(j,abs(pos[j]-pos[i])/power[i]); } for(i=0;i<m;i++) dis[i]=1000000000; dis[0]=0; pq.push({0,0}); while(pq.size()){ auto v=pq.top().second; pq.pop(); for(auto x:g[v]){ if(dis[v]+x.second<dis[x.first]){ dis[x.first]=dis[v]+x.second; pq.push({dis[x.first],x.first}); } } } if(dis[1]==1000000000) puts("-1"); else printf("%d\n",dis[1]); }

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

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