Submission #790065

#TimeUsernameProblemLanguageResultExecution timeMemory
790065thanh913Friend (IOI14_friend)C++14
100 / 100
21 ms3060 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pll = pair<ll, ll>; using pii = pair<int, int>; #define fi first #define se second #define eb emplace_back template<class X, class Y> bool cmax(X &a, const Y &b) { return a < b ? a = b, 1 : 0; } template<class X, class Y> bool cmin(X &a, const Y &b) { return a > b ? a = b, 1 : 0; } //-------------------------------------- const int N = 1e5+5; int f[N][2]; int findSample(int n, int confidence[], int host[], int protocol[]) { for (int i = 0; i < n; i++) { f[i][0] = confidence[i]; } for (int i = n-1; i > 0; i--) { switch (protocol[i]) { case 1: f[host[i]][0] = max({f[i][1] + f[host[i]][0], f[i][0] + f[host[i]][1], f[i][0] + f[host[i]][0]}); f[host[i]][1] += f[i][1]; break; case 2: f[host[i]][0] = max({f[i][1] + f[host[i]][0], f[i][0] + f[host[i]][1]}); f[host[i]][1] += f[i][1]; break; case 0: f[host[i]][0] += f[i][1]; f[host[i]][1] += max(f[i][1], f[i][0]); } } return max(f[0][0], f[0][1]); }
#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...