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 = 112345;
int dp[MAXN][2];
int findSample(int n,int confidence[],int host[],int protocol[]){
for(int i = 0; i < n; i++) {
dp[i][0] = 0; dp[i][1] = confidence[i];
}
for(int i = n - 1; i >= 1; i--) {
int cur = host[i];
if(protocol[i] == 0) {
dp[cur][0] = max(dp[i][0], dp[i][1]) + dp[cur][0];
dp[cur][1] = dp[i][0] + dp[cur][1];
}
else if(protocol[i] == 1) {
int d1 = dp[cur][0], d2 = dp[cur][1], d3 = dp[i][0], d4 = dp[i][1];
dp[cur][0] = d1 + d3;
dp[cur][1] = max(max(d2 + d3, d2 + d4), d4 + d1);
}
else {
int d1 = dp[cur][0], d2 = dp[cur][1], d3 = dp[i][0], d4 = dp[i][1];
dp[cur][0] = d1 + d3;
dp[cur][1] = max(d2 + d3, d1 + d4);
}
}
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... |