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;
using ll = long long;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL << (i))
// Find out best sample
ll dp[100100][2];
int findSample(int n,int confidence[],int p[],int protocol[]){
for (ll i = 0;i < n;i ++){
dp[i][1] = confidence[i];
dp[i][0] = 0;
}
for (ll i = n - 1;i >= 1;i --){
ll type = protocol[i];
ll pre[2];
pre[0] = dp[p[i]][0];
pre[1] = dp[p[i]][1];
dp[p[i]][0] = pre[0] + dp[i][0];
dp[p[i]][1] = pre[1] + dp[i][0];
if (type==0){
dp[p[i]][0] = max(dp[p[i]][0],pre[0] + dp[i][1]);
}
else if (type==1){
dp[p[i]][1] = max({dp[p[i]][1],pre[0] + dp[i][1],pre[1] + dp[i][1]});
}
else{
dp[p[i]][1] = max(dp[p[i]][1],pre[0] + dp[i][1]);
}
}
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... |