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<vector>
#include <algorithm>
using namespace std;
// Find out best sample
vector<vector<int>> g;
vector<array<int,2>> dp;
vector<int> val;
void dfs(int i){
dp[i][0] = dp[i][1] = 0;
for(auto u : g[i]){
dfs(u);
dp[i][0] += max(dp[u][1], dp[u][0]);
dp[i][1] += dp[u][0];
}
dp[i][1] += val[i];
}
int findSample(int n,int confidence[],int host[],int protocol[]){
g.resize(n);
dp.resize(n);
val.resize(n);
for(int i = 0; i < n; i ++){
val[i] = confidence[i];
}
for(int i = 1; i < n; i ++){
g[host[i]].push_back(i);
}
dfs(0);
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... |