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 pb push_back
#define mp make_pair
using namespace std;
vector< vector< pair<int,int> > > connect;
vector<bool> explored, isEnd;
int delve( int i ){
explored[i] = true;
if( isEnd[i] ){ return 0; }
vector<int> poss;
for( int j = 0; j < connect[i].size(); j++ ){
if ( !explored[ connect[i][j].first ] ){
int val = delve( connect[i][j].first );
if ( val != -1 ){
poss.pb( val + connect[i][j].second );
}
}
}
sort( poss.begin(), poss.end() );
if ( poss.size() < 2 ){ return -1; }
else{ return poss[1]; }
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
if ( M == N-1 ){
// do my thing -- pyramid explore
// set up helper values
connect.resize(N);
for( int i = 0; i < M; i++ ){
connect[ R[i][0] ].pb( mp( R[i][1], L[i] ) );
connect[ R[i][1] ].pb( mp( R[i][0], L[i] ) );
}
explored.resize(N, false);
isEnd.resize(N, false);
for( int i = 0; i < K; i++ ){ isEnd[ P[i] ] = true; }
return delve(0);
}
else{
return -1;
}
}
Compilation message (stderr)
crocodile.cpp: In function 'int delve(int)':
crocodile.cpp:20:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | for( int j = 0; j < connect[i].size(); j++ ){
| ~~^~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |