Submission #298604

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
2986042020-09-13 12:52:48emil_physmathFriend (IOI14_friend)C++17
100 / 100
38 ms7416 KiB
#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);
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...