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 <iostream>
#include <vector>
#define MAXN 1005
using namespace std;
vector<pair<int,int> > adj[MAXN];
int dp[MAXN];
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] = 1e9 + 10;
}
for (int i=0; i<K; i++) {
dp[P[i]]=0;
}
for (int i=0; i<M; i++) {
adj[R[i][0]].push_back({R[i][1], L[i]});
adj[R[i][1]].push_back({R[i][0], L[i]});
}
for (int j=0; j<N; j++) {
for (int i=0; i<N; i++) {
int Min=1e9 + 10, Smin = 1e9+10;
for (auto v: adj[i]) {
if (dp[v.first] + v.second < Min) {
Smin = Min;
Min = dp[v.first] + v.second;
} else if (dp[v.first] + v.second < Smin) {
Smin = dp[v.first] + v.second;
}
}
dp[i] = min(dp[i], Smin);
}
}
return(dp[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... |