Submission #497249

#TimeUsernameProblemLanguageResultExecution timeMemory
497249FerThugGato12500Crocodile's Underground City (IOI11_crocodile)C++17
0 / 100
1 ms2636 KiB
#include<bits/stdc++.h> using namespace std; #include "crocodile.h" const int lmt = 100005; struct wer{ int i; long long x; }; bool operator < (const wer &a, const wer &b){ return a.x > b.x; } bool mark[lmt]; bool vis[lmt]; vector< pair<int, int> > ed[lmt]; int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { for(int i = 0; i < N; i++){ ed[R[i][0]].push_back({R[i][1],L[i]}); ed[R[i][1]].push_back({R[i][0],L[i]}); } priority_queue<wer> mqun; for(int i = 0; i < K; i++){ mqun.push({P[i],0}); mark[P[i]] = true; } while(mqun.size()){ int ind = mqun.top().i; long long v = mqun.top().x; mqun.pop(); // cout<<ind<<" "<<v<<" : "; if(mark[ind]){ // cout<<"a\n"; if(ind==0){ return (int)(v); } vis[ind] = true; for(int i = 0; i < ed[ind].size(); i++){ int to = ed[ind][i].first; long long vs = v+ed[ind][i].second; if(!vis[to]){ mqun.push({to,vs}); } } }else { mark[ind] = true; // cout<<"b\n"; } } }

Compilation message (stderr)

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:39:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |             for(int i = 0; i < ed[ind].size(); i++){
      |                            ~~^~~~~~~~~~~~~~~~
crocodile.cpp:24:25: warning: control reaches end of non-void function [-Wreturn-type]
   24 |     priority_queue<wer> mqun;
      |                         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...