# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
298604 | emil_physmath | Friend (IOI14_friend) | C++17 | 38 ms | 7416 KiB |
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 <algorithm>
#include <numeric>
#include <vector>
#include <set>
#include "friend.h"
using namespace std;
using llong = long long;
const int maxN = 100'005;
set<int> nei[maxN];
enum Protocol { ME = 0, MY = 1, WE = 2 };
pair<int, int> SolveTree(int v, int* a)
{
pair<int, int> res(a[v], 0);
for (int to: nei[v])
{
pair<int, int> cur = SolveTree(to, a);
res.first += cur.second;
res.second += max(cur.first, cur.second);
}
return res;
}
int findSample(int n, int a[], int host[], int prot[]) {
if (count(prot + 1, prot + n, ME) == n - 1) {
for (int i = 1; i < n; ++i)
nei[host[i]].insert(i);
auto p = SolveTree(0, a);
return max(p.first, p.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... |