Submission #369162

#TimeUsernameProblemLanguageResultExecution timeMemory
369162NachoLibre친구 (IOI14_friend)C++17
100 / 100
31 ms3436 KiB
#include <bits/stdc++.h>
using namespace std;
#define sz(a) ((int)(a).size())
typedef vector<int> vint;
typedef vector<vint> vvint;
#ifndef wambule
#include "friend.h"
#else
#endif

int findSample(int n, int cfd[], int hst[], int ptc[]) {
	int x[n], y[n];
	for(int i = 0; i < n; ++i) {
		x[i] = cfd[i];
		y[i] = 0;
	}
	for(int i = n - 1; i > 0; --i) {
		int j = hst[i];
		if(ptc[i] == 0) {
			x[j] += y[i];
			y[j] += max(x[i], y[i]);
		} else if(ptc[i] == 1) {
			x[j] = max(x[i] + x[j], max(x[i] + y[j], y[i] + x[j]));
			y[j] += y[i];
		} else {
			x[j] = max(x[i] + y[j], y[i] + x[j]);
			y[j] += y[i];
		}
	}
	return max(x[0], y[0]);
}

#ifdef wambule
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	return 0;
}
#endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...