Submission #993740

#TimeUsernameProblemLanguageResultExecution timeMemory
993740firewaterFriend (IOI14_friend)C++14
100 / 100
18 ms3452 KiB
#include "friend.h" #include<bits/stdc++.h> #define ll long long #define N 100100 using namespace std; // Find out best sample int x,f[N],g[N]; int findSample(int n,int confidence[],int host[],int protocol[]){ memset(f,0,sizeof(f)); memset(g,0,sizeof(g)); for(int i=0;i<n;++i) f[i]=confidence[i]; for(int i=n-1;i>0;--i){ x=host[i]; f[i]=max(f[i],g[i]); if(protocol[i]==0)f[x]+=g[i],g[x]+=f[i]; else if(protocol[i]==1)f[x]=max(f[x]+f[i],g[x]+f[i]),g[x]+=g[i]; else f[x]=max(f[x]+g[i],g[x]+f[i]),g[x]+=g[i]; } return max(f[0],g[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...