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>
#define pb push_back
#define ll long long
using namespace std;
// Find out best sample
void getdp(int i, vector<int> children[], int n, int dp[][2], int confidence[]){
dp[i][0] = confidence[i]; dp[i][1] = 0;
if(children[i].empty())
return;
for(int x : children[i]){
getdp(x,children,n,dp,confidence);
dp[i][0]+=dp[x][1];
dp[i][1]+=dp[x][0];
}
}
int findSample(int n,int confidence[],int host[],int protocol[]){
int dp[n][2];
vector<int> children[n];
for(int i = 1; i<n; i++)
children[host[i]].pb(i);
getdp(0,children,n,dp,confidence);
return max(dp[0][0],dp[0][1]);
}
# | 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... |