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>
#define LL long long
#define ii pair<LL,LL>
#define F first
#define S second
using namespace std;
const int NN=1e3+100;
const int INF=1e18;
vector<ii> g[NN];
LL dp[NN];
vector<LL> vec;
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]=INF;
for(int i=0;i<K;i++)dp[P[i]]=0;
for(int i=0;i<M;i++){
LL u=R[i][0];
LL v=R[i][1];
LL w=L[i];
g[u].push_back({v,w});
g[v].push_back({u,w});
// cout<<u<<" "<<v<<" "<<w<<endl;
}
int h=N;
while(h--){
for(int i=0;i<N;i++){
vec.clear();
for(auto x:g[i]){
vec.push_back(dp[x.F]+x.S);
}
sort(vec.begin(),vec.end());
if(vec.size()>1){
dp[i]=min(dp[i],vec[1]);
}
}
}
LL ans=dp[0];
// for(int i=0;i<N;i++)cout<<dp[i]<<" ";cout<<endl;
return ans;
}
/*
5 4 3
0 1 2
0 2 3
3 2 1
2 4 4
1 3 4
5 7 2
0 2 4
0 3 3
3 2 2
2 1 10
0 1 100
0 4 7
3 4 9
1 3
*/
Compilation message (stderr)
crocodile.cpp:9:15: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
9 | const int INF=1e18;
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |