제출 #444285

#제출 시각아이디문제언어결과실행 시간메모리
444285GiselusJakarta Skyscrapers (APIO15_skyscraper)C++14
22 / 100
6 ms3404 KiB
#include<cstdio> #include<algorithm> #include<queue> #include<vector> #define S 30007 #define M 300 using namespace std; int B[S]; int P[S]; int n,m; int odw[S]; int odw2[S][M+7]; vector < int > doge[S]; priority_queue < pair < int, pair < int , int > >, vector < pair < int , pair < int , int > > > , greater < pair < int , pair < int , int > > > > q; void dijkstra(){ q.push({0,{0,B[0]}}); while(!q.empty()){ int koszt = q.top().first; int pies = q.top().second.first; int gdzie = q.top().second.second; q.pop(); if(!odw[gdzie]){ for(int i = 0; i < doge[gdzie].size();i++){ if(P[doge[gdzie][i]] <= M){ q.push({koszt,{doge[gdzie][i],gdzie}}); }else{ int p = 0; for(int j = gdzie; j >= 0; j -= P[doge[gdzie][i]]){ p++; q.push({koszt+p,{doge[gdzie][i],j}}); } p = 0; for(int j = gdzie; j < n; j += P[doge[gdzie][i]]){ p++; q.push({koszt+p,{doge[gdzie][i],j}}); } } } odw[gdzie] = koszt+1; } if(P[pies] <= M){ if(!odw2[gdzie][P[pies]]){ odw2[gdzie][P[pies]] = 1; if(gdzie - P[pies] >= 0) q.push({koszt+1,{pies, gdzie - P[pies]}}); if(gdzie + P[pies] < n) q.push({koszt+1,{pies, gdzie + P[pies]}}); } } } } int main(void){ scanf("%d %d",&n,&m); for(int i = 0; i < m;i++){ scanf("%d %d",&B[i],&P[i]); doge[B[i]].push_back(i); } dijkstra(); if(odw[B[1]]){ printf("%d",odw[B[1]]-1); }else{ printf("-1"); } return 0; } /* 5 3 0 2 1 1 4 1 */

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

skyscraper.cpp: In function 'void dijkstra()':
skyscraper.cpp:29:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |             for(int i = 0; i < doge[gdzie].size();i++){
      |                            ~~^~~~~~~~~~~~~~~~~~~~
skyscraper.cpp: In function 'int main()':
skyscraper.cpp:61:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |     scanf("%d %d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~
skyscraper.cpp:63:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         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...