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;
vector <int> v[100000];
int height[100000];
vector <int> level[100000];
int dp[100000][2];
int findSample(int n, int confidence[], int host[], int protocol[])
{
level[0].push_back(0);
for(int i = 1; i < n; i++)
{
v[host[i]].push_back(i);
height[i] = height[host[i]] + 1;
level[height[i]].push_back(i);
}
//cout<<"BBB"<<endl;
for(int i = n - 1; i >= 0; i--)
{
//cout<<"i: "<<i<<endl;
for(auto j : level[i])
{
dp[j][0] = confidence[j];
for(auto t : v[j])
dp[j][0] += dp[t][1];
dp[j][1] = 0;
for(auto t : v[j])
dp[j][1] += max(dp[t][0], dp[t][1]);
}
}
//cout<<"CCC"<<endl;
int res = max(dp[0][0], dp[0][1]);
return res;
}
# | 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... |