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;
const int maxn=100000+10;
pair<long long,long long>dp[maxn];
int findSample(int n,int confidence[],int host[],int protocol[]){
for(int i=0;i<n;i++){
dp[i].first=confidence[i];
dp[i].second=0;
}
for(int i=n-1;i>0;i--){
// cout<<i<<" "<<host[i]<<" "<<protocol[i]<<endl;
int p=host[i];
if(protocol[i]==0){
dp[p].first+=dp[i].second;
dp[p].second+=max(dp[i].first,dp[i].second);
}else if(protocol[i]==1){
dp[p].first=max(dp[i].first,dp[i].second)+max(dp[p].first,dp[p].second);
dp[p].second+=dp[i].second;
}else{
dp[p].first=max(dp[p].first+dp[i].second,dp[i].first+dp[p].second);
dp[p].second+=dp[i].second;
}
}
return max(dp[0].first,dp[0].second);
}
# | 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... |