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;
const int N=1e5+10;
int f[N][2];
// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[]){
for (int i=0; i<n; ++i) f[i][1]=confidence[i];
for (int v=n-1; v>0; --v){
int u=host[v];
if (protocol[v]==0){
f[u][0]=max(f[u][0]+f[v][0], f[u][0]+f[v][1]);
f[u][1]=f[u][1]+f[v][0];
}
if (protocol[v]==1){
f[u][1]=max({f[u][1]+f[v][0], f[u][0]+f[v][1], f[u][1]+f[v][1]});
f[u][0]=f[u][0]+f[v][0];
}
if (protocol[v]==2){
f[u][1]=max(f[u][1]+f[v][0], f[u][0]+f[v][1]);
f[u][0]=f[u][0]+f[v][0];
}
}
return max(f[0][0], f[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... |