Submission #808910

# Submission time Handle Problem Language Result Execution time Memory
808910 2023-08-05T12:20:55 Z OrazB Friend (IOI14_friend) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "friend.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ll long long int
#define pii pair <int, int>
#define pb push_back
#define ff first
#define ss second

const int N = 1e5+5;
int c[N], cur[2];
ll mx = 0;
vector<int> E[N];

void bit(int x, int n, int A[]){
	if (x == n){
		ll sum = 0;
		for (int i = 0; i < n; i++){
			if (c[i]){
				for (auto j : E[i]) if (c[j]) return;
				sum += A[i];
			}
		}
		mx = max(mx, sum);
		return;
	}
	for (int i = 0; i < 2; i++){
		c[x] = i;
		bit(x+1, n, A);
	}
}
void dfs(int nd, int pr, int t){
	cur[t] += A[nd];
	for (auto i : E[nd]){
		if (i != pr) dfs(i, nd, !t);
	}
}

int findSample(int n, int A[], int u[], int v[]){
	int sub0 = 0, sub1 = 0, sub2 = 0;
	int sum = 0;
	for (int i = 0; i < n; i++) sum += A[i];
	for (int i = 1; i < n; i++){
		if (v[i] == 2) sub2 = 1;
		if (v[i] == 0) sub0 = 1;
		if (v[i] == 1) sub1 = 1;
 		if (v[i] == 1 or v[i] == 2){
			for (auto j : E[u[i]]){
				E[i].pb(j);
				E[j].pb(i);
			}
		}
		if (v[i] == 0 or v[i] == 2){
			E[i].pb(u[i]);
			E[u[i]].pb(i);
		}
	}
	if (!sub0 and !sub2) return sum;
	if (!sub0 and !sub1) return *max_element(A, A+n);
	dfs(0, -1);
	if (!sub1 and !sub2) return max(cur[0], cur[1]);
	bit(0, n, A);
	return mx;
}


// int main ()
// {
// 	ios::sync_with_stdio(false);
// 	cin.tie(0);
// 	int n;
// 	cin >> n;
// 	int A[n], a[n], b[n];
// 	for (int i = 0; i < n; i++) cin >> A[i];
// 	for (int i = 1; i < n; i++) cin >> a[i] >> b[i];
// 	cout << findSample(n, A, a, b);
// }	

Compilation message

friend.cpp: In function 'void dfs(int, int, int)':
friend.cpp:34:12: error: 'A' was not declared in this scope
   34 |  cur[t] += A[nd];
      |            ^
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:61:11: error: too few arguments to function 'void dfs(int, int, int)'
   61 |  dfs(0, -1);
      |           ^
friend.cpp:33:6: note: declared here
   33 | void dfs(int nd, int pr, int t){
      |      ^~~