제출 #564766

#제출 시각아이디문제언어결과실행 시간메모리
564766hoanghq2004친구 (IOI14_friend)C++14
100 / 100
28 ms3000 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include "friend.h" using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; const int N = 1e5 + 10; int findSample(int n, int f[], int p[], int type[]) { int g[n]; memset(g, 0, sizeof(g)); for (int v = n - 1; v > 0; --v) { int u = p[v]; if (type[v] == 0) { f[u] += g[v]; g[u] += max(f[v], g[v]); } else if (type[v] == 2) { int nf = max(f[u] + g[v], g[u] + f[v]); int ng = g[u] + g[v]; f[u] = nf; g[u] = ng; } else { int nf = max({f[u] + f[v], f[u] + g[v], f[v] + g[u]}); int ng = g[u] + g[v]; f[u] = nf; g[u] = ng; } } return max(f[0], g[0]); }
#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...