Submission #232626

# Submission time Handle Problem Language Result Execution time Memory
232626 2020-05-17T17:29:09 Z crossing0ver Memory (IOI10_memory) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "grader.h"
using namespace std; 
int dp[1000006], C[1000006] , tot; 
void dfs(int v,int p) {
	dp[v] = 0;
	int s = 0;
	int r = 0;
	for (int i:adj[v]) {
		if (i != v) {
			r++;
			dfs (i,v);
			s += dp[i] + C[i];
			dp[v] = max(dp[v], dp[i] + C[i]);
		}
	}
}
vector <int> adj[1000005];
int LocateCentre(int n,int P[],int S[],int D[]) {
	  for (int i = 0; i < n-1; i++)
	  	adj[S[i]].push_back(D[i]),
	  	adj[D[i]].push_back(S[i]),
	  	C[i] = P[i], tot += C[i];
	pair<int,int> ans = {INT_MAX,-1};
	for (int i = 0; i < n; i++) {
		dfs(i,-1);
		if (ans < d)
		ans = min(ans,{dp[i],i});
	}
	return ans.second;
}

Compilation message

memory.cpp: In function 'void dfs(int, int)':
memory.cpp:9:13: error: 'adj' was not declared in this scope
  for (int i:adj[v]) {
             ^~~
memory.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
memory.cpp:27:13: error: 'd' was not declared in this scope
   if (ans < d)
             ^