Submission #528011

#TimeUsernameProblemLanguageResultExecution timeMemory
528011HydrolyzedTraffic (IOI10_traffic)C++14
Compilation error
0 ms0 KiB
/*
 * AUTHOR	: Hydrolyzed~
 * SCHOOL	: RYW
 * TASK		: IOI10_traffic
 * ALGO		: Dynamic Programming on Tree
 * DATE		: 19 Feb 2022
 * */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
// @==== Libary ====@ //
#include "traffic.h"
// @================@ //

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update> ;

// @=== Debugger ===@ //
#ifdef _DEBUG
#include "debug.hpp"
#else
#define dbg(...) 0
#endif
// @================@ //

using ll = long long;

const int MxN = 10000100;
int dp[MxN], pp[MxN], res = 1e9 + 1000, res_id;

void dfs(int u, int p){
	dp[u] = pp[u];
	for(auto x: adj[u]){
		if(x == p){
			continue;
		}
		dfs(x, u);
		dp[u] += dp[x];
	}
}

void dfs2(int u, int p, int last){
	int maxx = last;
	for(auto x: adj[u]){
		if(x == p){
			continue;
		}
		dfs2(x, u, last + dp[n] - dp[x]);
		maxx = max(maxx, dp[x]);
	}
	if(res > maxx){
		res = maxx;
		res_id = u;
	}
}

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]].puhs_back(s[i]);
	}
	memcpy(pp, p, sizeof p);
	dfs(0, 0);
	dfs2(0, 0, 0);
}

/*
inline void solution(){
	
	return ;
}

signed main(){
	cin.tie(nullptr)->ios::sync_with_stdio(false);	
	int q = 1;
//	cin >> q;
	while(q--){
		solution();
		cout << "\n";
	}
	return 0;
}
*/
// https://github.com/MasterIceZ/archive/tree/main/cpp-template

Compilation message (stderr)

traffic.cpp: In function 'void dfs(int, int)':
traffic.cpp:38:14: error: 'adj' was not declared in this scope
   38 |  for(auto x: adj[u]){
      |              ^~~
traffic.cpp: In function 'void dfs2(int, int, int)':
traffic.cpp:49:14: error: 'adj' was not declared in this scope
   49 |  for(auto x: adj[u]){
      |              ^~~
traffic.cpp:53:24: error: 'n' was not declared in this scope
   53 |   dfs2(x, u, last + dp[n] - dp[x]);
      |                        ^
traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:64:3: error: 'adj' was not declared in this scope
   64 |   adj[s[i]].push_back(d[i]);
      |   ^~~
traffic.cpp:67:23: warning: 'sizeof' on array function parameter 'p' will return size of 'int*' [-Wsizeof-array-argument]
   67 |  memcpy(pp, p, sizeof p);
      |                       ^
traffic.cpp:62:29: note: declared here
   62 | int LocateCentre(int n, int p[], int s[], int d[]){
      |                         ~~~~^~~
traffic.cpp:67:16: warning: argument to 'sizeof' in 'void* memcpy(void*, const void*, size_t)' call is the same expression as the source; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
   67 |  memcpy(pp, p, sizeof p);
      |                ^~~~~~~~
traffic.cpp:70:1: warning: no return statement in function returning non-void [-Wreturn-type]
   70 | }
      | ^