#include <bits/stdc++.h>
#include "friend.h"
using namespace std;
typedef long long ll;
int findSample(int n,int confidence[],int host[],int protocol[]){
ll select[n],hola[n];
for(ll i=0;i<n;i++){
select[i]=confidence[i];
hola[i]=0;
}
for(ll i=n-1;i>=1;--i){
ll u=host[i],v=i;
if(protocol[i]==0){
select[u]+=hola[v];
hola[u]=max(hola[u]+hola[v],hola[u]+select[v]);
}else if(protocol[i]==1){
select[u]=max({select[u]+select[v],select[u]+hola[v],hola[u]+select[v]});
hola[u]+=hola[v];
}else if(protocol[i]==2){
select[u]=max(select[u]+hola[v],hola[u]+select[v]);
hola[u]=hola[u]+hola[v];
}
}
return max(select[0],hola[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... |