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>
#define N 1000005
using namespace std;
int n, al[N], alma[N], yal[N], yalma[N];
int findSample(int n,int c[],int h[],int p[]){
for(int i = 0; i < n; i++){
al[i] = c[i];
alma[i] = 0;
}
for(int y = n - 1; y >= 1; y--){
int x = h[y];
if(p[y] == 2){
yalma[x] = alma[x] + alma[y];
yal[x] = max(al[y] + alma[x], alma[y] + al[x]);
} else if(p[y] == 1){
yalma[x] = alma[x] + alma[y];
yal[x] = max(max(al[x] + alma[y], alma[x] + al[y]), al[x] + al[y]);
} else{
yalma[x] = alma[x] + max(al[y], alma[y]);
yal[x] = al[x] + alma[y];
}
swap(yal[x], al[x]);
swap(yalma[x], alma[x]);
}
return max(al[0], alma[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... |