이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |