제출 #320122

#제출 시각아이디문제언어결과실행 시간메모리
320122NicolaAbusaad2014Jakarta Skyscrapers (APIO15_skyscraper)C++14
36 / 100
655 ms262148 KiB
/** * Prof.Nicola **/ #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n,m,z; cin>>n>>m; long long skyscraper[m],jumps[m]; vector<long long>doges[n]; vector<long long>vis(m,-1e9); for(long i=0;i<m;i++){ cin>>skyscraper[i]>>jumps[i]; doges[skyscraper[i]].push_back(i); } if(skyscraper[0]==skyscraper[1]){ cout<<0<<endl; } else{ priority_queue<pair<long long,long> >pq; pq.push(make_pair(0,0)); long long cost,doge,pos,x; while(!pq.empty()){ cost=pq.top().first; doge=pq.top().second; pos=skyscraper[doge]; pq.pop(); if(cost>vis[doge]){ vis[doge]=cost; z=pos%jumps[doge]; for(long i=z;i<n;i+=jumps[doge]){ x=abs(i-pos); x/=jumps[doge]; for(long j=0;j<doges[i].size();j++){ if(cost-x>vis[doges[i][j]]){ pq.push(make_pair(cost-x,doges[i][j])); } } } } } if(vis[1]==-1e9){ cout<<-1<<endl; } else{ cout<<-vis[1]<<endl; } } return 0; }

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

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:39:27: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |             for(long j=0;j<doges[i].size();j++){
      |                          ~^~~~~~~~~~~~~~~~
#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...