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 maxn 100005
int take[maxn],notake[maxn];
// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[]){
for(int i=0;i<n;++i)take[i]=confidence[i];
for(int i=n-1;i>0;--i){
int h=host[i];
if(protocol[i]==0){//i am your friend
take[h]+=notake[i];
notake[h]+=max(take[i],notake[i]);
}
else if(protocol[i]==1){//my friends are your friends
take[h]=max(take[h]+take[i],max(take[h]+notake[i],notake[h]+take[i]));
notake[h]+=notake[i];
}
else{//we are your friends
take[h]=max(take[h]+notake[i],notake[h]+take[i]);
notake[h]+=notake[i];
}
}
return max(take[0],notake[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... |