Submission #404202

#TimeUsernameProblemLanguageResultExecution timeMemory
404202ly20Friend (IOI14_friend)C++17
100 / 100
31 ms3124 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 112345; int dp[MAXN][2]; int findSample(int n,int confidence[],int host[],int protocol[]){ for(int i = 0; i < n; i++) { dp[i][0] = 0; dp[i][1] = confidence[i]; } for(int i = n - 1; i >= 1; i--) { int cur = host[i]; if(protocol[i] == 0) { dp[cur][0] = max(dp[i][0], dp[i][1]) + dp[cur][0]; dp[cur][1] = dp[i][0] + dp[cur][1]; } else if(protocol[i] == 1) { int d1 = dp[cur][0], d2 = dp[cur][1], d3 = dp[i][0], d4 = dp[i][1]; dp[cur][0] = d1 + d3; dp[cur][1] = max(max(d2 + d3, d2 + d4), d4 + d1); } else { int d1 = dp[cur][0], d2 = dp[cur][1], d3 = dp[i][0], d4 = dp[i][1]; dp[cur][0] = d1 + d3; dp[cur][1] = max(d2 + d3, d1 + d4); } } return max(dp[0][0], dp[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...