Submission #551818

#TimeUsernameProblemLanguageResultExecution timeMemory
551818QuantumK9Crocodile's Underground City (IOI11_crocodile)C++17
46 / 100
2 ms444 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...