Submission #702071

#TimeUsernameProblemLanguageResultExecution timeMemory
702071PCTprobabilityFriend (IOI14_friend)C++17
27 / 100
2 ms2692 KiB
#include <bits/stdc++.h> #include "friend.h" using namespace std; using ll = long long; #define pb push_back vector<int> g[100000]; int dp[100000][2]; ll con[100000]; void dfs(int a,int b){ for(auto e:g[a]){ if(e==b) continue; dfs(e,a); dp[a][0]+=max(dp[e][0],dp[e][1]); dp[a][1]+=dp[e][0]; } dp[a][1]+=con[a]; } int findSample(int n, int confidence[], int host[], int protocol[]){ for(int i=0;i<n;i++) con[i]=confidence[i]; for(int i=n-1;i>=1;i--){ assert(host[i]<i); dp[i][1]+=con[i]; dp[i][1]=max(dp[i][1],dp[i][0]); if(protocol[i]==0){ dp[host[i]][0]+=dp[i][1]; dp[host[i]][1]+=dp[i][0]; } if(protocol[i]==1){ dp[host[i]][0]+=dp[i][0]; dp[host[i]][1]+=dp[i][1]; } if(protocol[i]==2){ } } dp[0][1]+=con[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...