This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |