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;
typedef long long ll;
#define all(v) v.begin(), v.end()
// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[]){
vector<int> c(n), nc(n, 0);
for (int i = 0; i < n; i++) {
c[i] = confidence[i];
}
for (int i = n - 1; i > 0; i--) {
if(protocol[i] == 0){
c[host[i]] = nc[i] + c[host[i]];
nc[host[i]] = max(nc[host[i]] + nc[i], nc[host[i]] + c[i]);
}
else if(protocol[i] == 1){
c[host[i]] = max(nc[host[i]] + c[i], max(c[host[i]] + nc[i], c[host[i]] + c[i]));
nc[host[i]] = nc[i] + nc[host[i]];
}
else {
c[host[i]] = max(c[host[i]] + nc[i], c[i] + nc[host[i]]);
nc[host[i]] = nc[i] + nc[host[i]];
}
}
return max(c[0], nc[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... |