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;
int findSample(int n,int confidence[],int host[],int protocol[]){
vector <int> p(n), q(n);
for(int i = 0; i < n; i++) {
p[i] = confidence[i];
}
for(int i = n - 1; i > 0; i--) {
int id = host[i], t = protocol[i];
int P = p[id], Q = q[id];
if(t == 0) {
p[id] = q[i] + P;
q[id] = max(Q + q[i], p[i] + Q);
}
if(t == 1) {
p[id] = max(P + q[i], p[i] + max(P, Q));
q[id] = Q + q[i];
}
if(t == 2) {
p[id] = max(P + q[i], Q + p[i]);
q[id] = Q + q[i];
}
}
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... |