이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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[c][1]+max(dp[d][0],dp[d][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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |