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>
#define fi first
#define se second
#define lo long long
#define inf 1000000000
#define md 1000000007
#define li 100005
#define mp make_pair
#define pb push_back
#define pi pair<lo int, int>
using namespace std;
int findSample(int n, int confidence[], int host[], int protocol[]){
int P[li], Q[li] = {0};
for(int i=0;i<n;i++){
P[i]=confidence[i];
}
for(int i=n-1;i>=1;i--){
int x=host[i];
int y=i;
if(protocol[i]==0){
Q[x]=max(Q[x]+Q[y],Q[x]+P[y]);
P[x]=P[x]+Q[y];
}
if(protocol[i]==1){
P[x]=max(P[x]+P[y],max(Q[x]+P[y],Q[y]+P[x]));
Q[x]=Q[x]+Q[y];
}
if(protocol[i]==2){
P[x]=max(P[x]+Q[y],Q[x]+P[y]);
Q[x]=Q[x]+Q[y];
}
}
return max(Q[0],P[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... |