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;
// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[]){
vector<array<int, 2>> dp(n);
for (int i = 0; i < n; i++) dp[i][0] = 0, dp[i][1] = confidence[i];
for (int i = n-1; i > 0; i--)
{
int pai = host[i]; int type = protocol[i];
if (type == 0)
{
dp[pai][1] = dp[pai][1] + dp[i][0];
dp[pai][0] = dp[pai][0] + max(dp[i][0], dp[i][1]);
}
else if (type == 1)
{
dp[pai][1] = max({dp[pai][1] + dp[i][1], dp[pai][1] + dp[i][0], dp[pai][0] + dp[i][1]});
dp[pai][0] = dp[pai][0] + dp[i][0];
}
else
{
dp[pai][1] = max(dp[pai][1] + dp[i][0], dp[pai][0] + dp[i][1]);
dp[pai][0] = dp[pai][0] + dp[i][0];
}
}
return max(dp[0][1], dp[0][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... |