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 <bits/stdc++.h>
using namespace std;
vector < pair < int, int > > gr[1111];
long long dist[1111];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
for(int i = 0; i < M; i ++ ){
gr[R[i][0]].push_back({L[i], R[i][1]});
gr[R[i][1]].push_back({L[i], R[i][0]});
}
for( int i = 0; i < N; i ++ ){
dist[i] = 2e9;
}
for( int i = 0; i < K; i ++ ){
dist[P[i]] = 0;
}
for( int j = 0; j < N; j ++ ){
for( int i = 0; i < N; i ++ ){
long long min1 = 2e9, min2 = 2e9;
for( auto edge: gr[i] ){
int cost = edge.first, to = edge.second;
if(dist[to]+cost<min1){
min2 = min1;
min1 = dist[to] + cost;
}
else if( dist[to]+cost<min2){
min2 = dist[to] + cost;
}
}
//cout << "--> " << j << " : " << i << ' ' << min1 << ' ' << min2<<endl;
dist[i] = min(dist[i], min2);
}
}
/*
for( int i = 0; i < N; i ++ ){
cout << i << ' ' << dist[i] << endl;
}*/
return dist[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... |