Submission #772053

#TimeUsernameProblemLanguageResultExecution timeMemory
772053PixelCatFriend (IOI14_friend)C++14
100 / 100
21 ms3112 KiB
#ifdef NYAOWO #include "grader.cpp" #endif #include "friend.h" #include <bits/stdc++.h> #define For(i, a, b) for(int i = a; i <= b; i++) #define Forr(i, a, b) for(int i = a; i >= b; i--) using namespace std; const int MAXN = 100010; int dp0[MAXN + 10]; int dp1[MAXN + 10]; inline void chmax(int &a, const int &b) { if(a < b) a = b; } // Find out best sample int findSample(int n,int val[],int par[],int op[]){ For(i, 0, n - 1) { dp0[i] = 0; dp1[i] = val[i]; } Forr(i, n - 1, 1) { int p = par[i]; if(op[i] == 0) { dp1[p] += dp0[i]; dp0[p] += max(dp0[i], dp1[i]); } else if(op[i] == 2) { dp1[p] = max(dp1[p] + dp0[i], dp0[p] + dp1[i]); dp0[p] += dp0[i]; } else if(op[i] == 1) { dp1[p] = max(dp1[p] + max(dp0[i], dp1[i]), dp0[p] + dp1[i]); dp0[p] += dp0[i]; } } return max(dp0[0], dp1[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...