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<bits/stdc++.h>
#include "friend.h"
using namespace std;
const int MAXN = 1e5+1;
int val[2][MAXN];
int findSample(int n, int confidence[], int host[], int protocol[]){
int ans = 0;
for(int i=0; i<n; ++i) {
val[0][i] = 0;
val[1][i] = confidence[i];
}
for(int i=n-1; i>=1; --i) {
if(protocol[i]==0) {
val[0][host[i]] += max(val[0][i], val[1][i]);
val[1][host[i]] += val[0][i];
}
if(protocol[i]==1) {
val[1][host[i]] = max(val[0][host[i]], val[1][host[i]]) + max(val[0][i], val[1][i]);
val[0][host[i]] += val[0][i];
}
if(protocol[i]==2) {
val[1][host[i]] = max({val[1][host[i]]+val[0][i], val[0][host[i]]+val[1][i], val[0][host[i]]+val[0][i]});
val[0][host[i]] += val[0][i];
}
//cerr<<i<<": "<<val[0][1]<<' '<<val[1][1]<<'\n';
//cerr<<" "<<val[0][0]<<' '<<val[1][0]<<'\n';
}
ans = max(val[0][0], val[1][0]);
return ans;
}
# | 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... |