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>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
using PII = pair<int, int>;
#define ST first
#define ND second
int findSample(int n, int confidence[], int host[], int protocol[]){
vector<PII> dp(n);
REP(i, n) dp[i] = {confidence[i], 0};
for(int i = n - 1; i >= 1; i--) {
int j = host[i];
if(protocol[i] == 0) {
dp[j] = {
dp[j].ST + dp[i].ND,
dp[j].ND + max(dp[i].ST, dp[i].ND)
};
}
else if(protocol[i] == 1) {
dp[j] = {
max({dp[j].ST + dp[i].ST, dp[j].ST + dp[i].ND, dp[j].ND + dp[i].ST}),
dp[i].ND + dp[j].ND
};
}
else if(protocol[i] == 2) {
dp[j] = {
max(dp[j].ST + dp[i].ND, dp[j].ND + dp[i].ST),
dp[j].ND + dp[i].ND
};
}
}
return max(dp[0].ST, dp[0].ND);
}
# | 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... |