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