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> yes(n), no(n, 0);
for (int i = 0; i < n; i++) yes[i] = confidence[i];
for (int i = n - 1; i >= 1; i--){
int par = host[i];
if (protocol[i] == 0){
yes[par] += no[i];
no[par] += max(yes[i], no[i]);
}
else if (protocol[i] == 1){
yes[par] = max(yes[par] + yes[i], max(yes[par] + no[i], no[par] + yes[i]));
no[par] += no[i];
}
else{
yes[par] = max(yes[par] + no[i], no[par] + yes[i]);
no[par] += no[i];
}
}
return max(yes[0], no[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... |