제출 #935350

#제출 시각아이디문제언어결과실행 시간메모리
935350tamir1Jakarta Skyscrapers (APIO15_skyscraper)C++14
36 / 100
353 ms262144 KiB
#include<bits/stdc++.h> #define ll long long #define ff first #define ss second using namespace std; ll n,m,i,j,dist[200005],b[200005],p[200005],x,y; vector<pair<ll,ll>> v[200005]; bitset<200005> vis; priority_queue<pair<ll,ll>> q; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for(i=0;i<m;i++){ cin >> b[i] >> p[i]; x=b[i]+p[i]; y=0; while(x<n){ y++; v[b[i]].push_back({x,y}); x+=p[i]; } x=b[i]-p[i]; y=0; while(x>=0){ y++; v[b[i]].push_back({x,y}); x-=p[i]; } } q.push({0,b[0]}); while(!q.empty()){ x=q.top().ss; y=q.top().ff; q.pop(); if(vis[x]) continue; dist[x]=-y; vis[x]=1; for(i=0;i<v[x].size();i++){ if(!vis[v[x][i].ff]){ q.push({y-v[x][i].ss,v[x][i].ff}); } } } if(vis[b[1]]) cout << dist[b[1]]; else cout << -1; }

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

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:40:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |   for(i=0;i<v[x].size();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...