Submission #776297

#TimeUsernameProblemLanguageResultExecution timeMemory
776297ThegeekKnight16Friend (IOI14_friend)C++17
100 / 100
21 ms3460 KiB
#include <bits/stdc++.h> #include "friend.h" using namespace std; // Find out best sample int findSample(int n,int confidence[],int host[],int protocol[]){ vector<array<int, 2>> dp(n); for (int i = 0; i < n; i++) dp[i][0] = 0, dp[i][1] = confidence[i]; for (int i = n-1; i > 0; i--) { int pai = host[i]; int type = protocol[i]; if (type == 0) { dp[pai][1] = dp[pai][1] + dp[i][0]; dp[pai][0] = dp[pai][0] + max(dp[i][0], dp[i][1]); } else if (type == 1) { dp[pai][1] = max({dp[pai][1] + dp[i][1], dp[pai][1] + dp[i][0], dp[pai][0] + dp[i][1]}); dp[pai][0] = dp[pai][0] + dp[i][0]; } else { dp[pai][1] = max(dp[pai][1] + dp[i][0], dp[pai][0] + dp[i][1]); dp[pai][0] = dp[pai][0] + dp[i][0]; } } return max(dp[0][1], dp[0][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...