Submission #17292

#TimeUsernameProblemLanguageResultExecution timeMemory
17292erdemkirazFriend (IOI14_friend)C++98
100 / 100
44 ms3676 KiB
#include <bits/stdc++.h>

using namespace std;

#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); it++)
typedef long long ll;
typedef pair < int, int > ii;

const int inf = 1e9 + 333;
const ll linf = 1e18 + inf;

#include "friend.h"

const int N = 100000 + 5;

int a[N], b[N];

// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[]) {
	for(int i = 0; i < n; i++) {
		a[i] = confidence[i];
	}
	for(int i = n - 1; i >= 1; i--) {
		int j = host[i];
		if(protocol[i] == 0) {
			int x = a[j] + b[i];
			int y = max(a[i], b[i]) + b[j];
			a[j] = x;
			b[j] = y;
		}
		else if(protocol[i] == 1) {
			int x = max(max(a[j] + a[i], a[j] + b[i]), b[j] + a[i]);
			int y = b[j] + b[i];
			a[j] = x;
			b[j] = y;
		}
		else {
			int x = max(a[j] + b[i], b[j] + a[i]);
			int y = b[j] + b[i];
			a[j] = x;
			b[j] = y;
		}
	}
	return max(a[0], b[0]);
}
#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...