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 "friend.h"
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << ": " << x << endl;
const int MAXN = 1e5 + 10;
int C[MAXN], P[MAXN], Q[MAXN];
int findSample(int n, int C_[], int host[], int protocol[]){
for (int i = 0; i < n; i++)
P[i] = C_[i];
for (int i = n - 1; i > 0; i--) {
int h = host[i];
if (protocol[i] == 2) {
P[h] = max(P[h] + Q[i], P[i] + Q[h]);
Q[h] = Q[i] + Q[h];
} else if (protocol[i] == 1) {
P[h] = max({P[h] + P[i], P[h] + Q[i], P[i] + Q[h]});
Q[h] = Q[i] + Q[h];
} else {
P[h] = P[h] + Q[i];
Q[h] = Q[h] + max(P[i], Q[i]);
}
P[h] = max(P[h], Q[h]);
}
return max(Q[0], P[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... |