Submission #234717

# Submission time Handle Problem Language Result Execution time Memory
234717 2020-05-25T10:42:02 Z Dilshod_Imomov Crocodile's Underground City (IOI11_crocodile) C++17
Compilation error
0 ms 0 KB
#include "crocodile.h"
using namespace std;

const int NN = 1e3 + 7;

vector < pair < int, int > > adj[NN];
int dp[NN], l[NN];

void dfs( int v, int p ) {
	int mn1 = 0, mn2 = 0;
	// cout << v << ' ' << p << '\n';
	for ( auto pr: adj[v] ) {
		int u = pr.first, ind = pr.second;
		if ( u != p ) {
			dfs( u, v );
			int cnt = dp[u] + l[ind];
			if ( cnt <= mn1 ) {
				mn2 = mn1;
				mn1 = cnt;
			}
			else if ( cnt < mn2 ) {
				mn2 = cnt;
			}
		}
	}
	if ( mn2 == 0 ) {
		mn2 = mn1;
	}
	dp[v] = mn2;
}

int travel_plan(int n, int m, int R[][2], int L[], int K, int P[])
{
	for ( int i = 0; i < m; i++ ) {
		int u = R[i][0], v = R[i][1];
		adj[u].push_back( { v, i } );
		adj[v].push_back( { u, i } );
		l[i] = L[i];
	}
	dfs( 0, 0 );
	return dp[0];
}


Compilation message

crocodile.cpp:6:1: error: 'vector' does not name a type
 vector < pair < int, int > > adj[NN];
 ^~~~~~
crocodile.cpp: In function 'void dfs(int, int)':
crocodile.cpp:12:17: error: 'adj' was not declared in this scope
  for ( auto pr: adj[v] ) {
                 ^~~
crocodile.cpp:16:24: error: 'ind' was not declared in this scope
    int cnt = dp[u] + l[ind];
                        ^~~
crocodile.cpp:16:24: note: suggested alternative: 'int'
    int cnt = dp[u] + l[ind];
                        ^~~
                        int
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:36:3: error: 'adj' was not declared in this scope
   adj[u].push_back( { v, i } );
   ^~~