Submission #223365

#TimeUsernameProblemLanguageResultExecution timeMemory
223365staniewzkiFriend (IOI14_friend)C++17
100 / 100
40 ms3448 KiB
#include<bits/stdc++.h> using namespace std; #define REP(i, n) for(int i = 0; i < n; i++) using PII = pair<int, int>; #define ST first #define ND second int findSample(int n, int confidence[], int host[], int protocol[]){ vector<PII> dp(n); REP(i, n) dp[i] = {confidence[i], 0}; for(int i = n - 1; i >= 1; i--) { int j = host[i]; if(protocol[i] == 0) { dp[j] = { dp[j].ST + dp[i].ND, dp[j].ND + max(dp[i].ST, dp[i].ND) }; } else if(protocol[i] == 1) { dp[j] = { max({dp[j].ST + dp[i].ST, dp[j].ST + dp[i].ND, dp[j].ND + dp[i].ST}), dp[i].ND + dp[j].ND }; } else if(protocol[i] == 2) { dp[j] = { max(dp[j].ST + dp[i].ND, dp[j].ND + dp[i].ST), dp[j].ND + dp[i].ND }; } } return max(dp[0].ST, dp[0].ND); }
#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...