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 <bits/stdc++.h>
#include "friend.h"
using namespace std;
/*******************/
#define pi pair<int,int>
#define ll long long
#define f first
#define s second
#define pb push_back
int findSample(int n,int confidence[],int host[],int protocol[]){
vector<int> yes(n, 0), no(n, 0);
for(int i =0;i<n ;i++) yes[i] = confidence[i];
for(int i=n-1; i>0; i--){
if(protocol[i]== 0){//yo soy tu amigo
yes[host[i]] += no[i];
no[host[i]] += max(yes[i], no[i]);
}
else if(protocol[i] == 1){//mis amigos son tus amigos
yes[host[i]] = max({yes[i] + no[host[i]],yes[host[i]] + no[i], yes[i] + yes[host[i]]});
no[host[i]] += no[i];
}
else{//somos tus amigos
yes[host[i]] = max(yes[i] + no[host[i]], no[i] + yes[host[i]]);
no[host[i]] += no[i];
}
}
return max(yes[0], no[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... |