This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |