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;
#define st first
#define nd second
#define sz(x) (x.size())
#define pb push_back
#define N 100005
int findSample(int n,int confidence[],int host[],int protocol[]) {
int P[N],Q[N]={0};
for(int i=0;i<n;i++) P[i]=confidence[i];
for(int i=n-1;i>=0;i--) {
int x=host[i];
int y=i;
if(protocol[i]==0) {
Q[x]=max(Q[x]+Q[y],P[y]+Q[x]);
P[x]=P[x]+Q[y];
}
if(protocol[i]==1) {
P[x]=max(max(P[x]+Q[y],P[y]+Q[x]),P[x]+P[y]);
Q[x]=Q[y]+Q[x];
}
if(protocol[i]==2) {
P[x]=max(P[y]+Q[x],P[x]+Q[y]);
Q[x]=Q[x]+Q[y];
}
}
return max(P[0],Q[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... |