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;
int findSample(int n, int confidence[], int host[], int protocol[]){
pair<int, int> ans[n];
for(int i = 0; i < n; i++) ans[i] = {confidence[i], 0};
for(int i = n - 1; i >= 1; i--){
int h = host[i];
if(protocol[i] == 0) ans[h] = {ans[h].first + ans[i].second, max(ans[h].second + ans[i].first, ans[h].second + ans[i].second)};
else if(protocol[i] == 1) ans[h] = {max({ans[h].first + ans[i].first, ans[h].first + ans[i].second, ans[h].second + ans[i].first}), ans[h].second + ans[i].second};
else if(protocol[i] == 2) ans[h] = {max(ans[h].first + ans[i].second, ans[h].second + ans[i].first), ans[h].second + ans[i].second};
}
return max(ans[0].first, ans[0].second);
}
# | 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... |