Submission #602870

#TimeUsernameProblemLanguageResultExecution timeMemory
602870mosiashvililukaFriend (IOI14_friend)C++14
27 / 100
26 ms4556 KiB
#include "friend.h" #include<bits/stdc++.h> using namespace std; int a,b,c,d,e,i,j,ii,jj,zx,xc,f[100009],H[100009],dp[100009][2],P[100009]; int findSample(int Nn,int Conf[],int HS[],int PROT[]){ a=Nn; for(i=1; i<=a; i++) f[i]=Conf[i-1]; for(i=2; i<=a; i++) H[i]=HS[i-1]+1; for(i=2; i<=a; i++) P[i]=PROT[i-1]; for(i=1; i<=a; i++){ dp[i][0]=f[i];dp[i][1]=0; } for(i=a; i>=2; i--){ c=H[i];d=i; //cout<<c<<" "<<d<<" "<<dp[c][0]<<" "<<dp[c][1]<<" "<<dp[d][0]<<" "<<dp[d][1]<<"\n"; if(P[i]==0){ zx=dp[c][0]+dp[d][1]; xc=dp[d][0]+dp[c][1]; dp[c][0]=zx;dp[c][1]=xc; //cout<<dp[c][0]<<" "<<dp[c][1]<<"\n"; continue; } if(P[i]==1){ zx=max(dp[c][0]+dp[d][0],max(dp[c][0]+dp[d][1],dp[d][0]+dp[c][1])); xc=dp[c][1]+dp[d][1]; dp[c][0]=zx;dp[c][1]=xc; //cout<<dp[c][0]<<" "<<dp[c][1]<<"\n"; continue; } if(P[i]==2){ zx=max(dp[c][0]+dp[d][1],dp[d][0]+dp[c][1]); xc=dp[c][1]+dp[d][1]; dp[c][0]=zx;dp[c][1]=xc; //cout<<dp[c][0]<<" "<<dp[c][1]<<"\n"; continue; } } return max(dp[1][0],dp[1][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...