Submission #296959

#TimeUsernameProblemLanguageResultExecution timeMemory
296959HemimorCrocodile's Underground City (IOI11_crocodile)C++14
100 / 100
727 ms53548 KiB
#include "crocodile.h" #include <algorithm> #include <iostream> #include <iomanip> #include <numeric> #include <cassert> #include <vector> #include <cmath> #include <queue> #include <set> #include <map> #define syosu(x) fixed<<setprecision(x) using namespace std; typedef long long ll; typedef unsigned int uint; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<double,double> pdd; typedef pair<ll,ll> pll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<double> vd; typedef vector<vd> vvd; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<string> vs; typedef vector<pii> vp; typedef vector<vp> vvp; typedef vector<pll> vpll; typedef pair<pii,int> pip; typedef vector<pip> vip; const int inf=1<<30; const ll INF=1ll<<60; const double pi=acos(-1); const double eps=1e-8; const ll mod=1e9+7; const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1}; int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){ vvp g(N); for(int i=0;i<M;i++){ int u=R[i][0],v=R[i][1]; g[u].push_back({v,L[i]}); g[v].push_back({u,L[i]}); } vl c(N,INF),d(N,INF),vis(N); priority_queue<pll> q; for(int i=0;i<K;i++){ c[P[i]]=d[P[i]]=0; q.push({0,P[i]}); } while(!q.empty()){ auto p=q.top();q.pop(); ll v=p.second; if(d[v]!=-p.first||vis[v]) continue; vis[v]++; // cout<<v<<' '<<d[v]<<endl; for(auto pp:g[v]){ ll u=pp.first,w=pp.second,t=d[v]+w; if(t<d[u]&&!vis[u]){ if(t<c[u]){ d[u]=c[u]; c[u]=t; } else d[u]=t; q.push({-d[u],u}); } } } // cout<<c[0]<<' '<<d[0]<<endl; return (int)d[0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...