| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 296639 | emil_physmath | Friend (IOI14_friend) | C++17 | 3 ms | 2816 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 "friend.h"
using namespace std;
using llong = long long;
const int maxN = 100'005;
vector<int> chld[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: chld[v])
{
pair<int, int> cur = SolveTree(to, a);
res.first += cur.second;
res.second += max(cur.first, cur.second);
}
return res;
}
// Find out best sample
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)
chld[host[i]].push_back(i);
auto p = SolveTree(0, a);
return max(p.first, p.second);
}
if (count(prot + 1, prot + n, MY) == n - 1)
return accumulate(a, a + n, 0);
if (count(prot + 1, prot + n, WE) == n - 1)
return *max_element(a, a + n);
}
Compilation message (stderr)
| # | 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... | ||||
