Submission #519713

#TimeUsernameProblemLanguageResultExecution timeMemory
519713antonioqbabCrocodile's Underground City (IOI11_crocodile)C++14
100 / 100
470 ms71108 KiB
#include <bits/stdc++.h> //#include <crocodile.h> using namespace std; using ll = long long; using pi = pair<int,int>; int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){ vector<vector<pair<int,int>>> G(n); vector<int> seen(n); for(int i=0;i<m;++i){ int x,y; G[r[i][0]].emplace_back(r[i][1], l[i]); G[r[i][1]].emplace_back(r[i][0], l[i]); } auto comp=[&](pi a, pi b){ return a.second>b.second; }; priority_queue<pi,vector<pi>,decltype(comp)> PQ(comp); for(int i=0;i<k;++i){ PQ.emplace(p[i], 0); ++seen[p[i]]; } while(!PQ.empty()){ int node, cost; tie(node, cost)=PQ.top(); PQ.pop(); if(++seen[node]==2){ if(node==0) return cost; for(auto x:G[node]) PQ.emplace(x.first,x.second+cost); } } }

Compilation message (stderr)

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:12:7: warning: unused variable 'x' [-Wunused-variable]
   12 |   int x,y;
      |       ^
crocodile.cpp:12:9: warning: unused variable 'y' [-Wunused-variable]
   12 |   int x,y;
      |         ^
crocodile.cpp:9:35: warning: control reaches end of non-void function [-Wreturn-type]
    9 |  vector<vector<pair<int,int>>> G(n);
      |                                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...