Submission #123846

#TimeUsernameProblemLanguageResultExecution timeMemory
123846baluteshihCrocodile's Underground City (IOI11_crocodile)C++14
89 / 100
2056 ms80444 KiB
#include "crocodile.h" #include<bits/stdc++.h> #define MP make_pair #define F first #define S second #define pb push_back #define MEM(i,j) memset(i,j,sizeof i) #define ET cout << "\n" #define ALL(v) v.begin(),v.end() #define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;} using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll INF=1e18; vector<pll> G[100005]; pll dp[100005]; bitset<100005> vis; int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { for(int i=0;i<N;++i) dp[i]=MP(INF,INF); for(int i=0;i<M;++i) G[R[i][0]].pb(MP(L[i],R[i][1])),G[R[i][1]].pb(MP(L[i],R[i][0])); for(int i=0;i<K;++i) dp[P[i]]=MP(0,0); for(int i=0;i<N;++i) { int mi=-1; for(int j=0;j<N;++j) if(!vis[j]&&(!~mi||dp[j].S<dp[mi].S)) mi=j; vis[mi]=1; for(auto j:G[mi]) if(!vis[j.S]) { ll x=dp[mi].S+j.F; if(x<dp[j.S].F) dp[j.S].S=dp[j.S].F,dp[j.S].F=x; else if(x<dp[j.S].S) dp[j.S].S=x; } } return dp[0].S; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...