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 SZ 666666
int f[SZ],g[SZ];
int findSample(int n,int c[],int fa[],int p[]){
for(int i=0;i<n;++i) f[i]=c[i];
for(int i=n-1;i>0;--i)
{
int t=fa[i];
if(p[i]==0)
f[t]+=g[i],g[t]+=max(f[i],g[i]);
else if(p[i]==1)
f[t]=max(f[t]+max(f[i],g[i]),g[t]+f[i]),g[t]+=g[i];
else
f[t]=max(f[t]+g[i],g[t]+f[i]),g[t]+=g[i];
}
return max(f[0],g[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... |