이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "friend.h"
#include <bits/stdc++.h>
using namespace std;
// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[]){
vector<int> take(n);
vector<int> leave(n);
for (int i = 0; i<n; i++){
take[i]=confidence[i];
}
for (int i = n-1; i>0; i--){
//unmerge elements host[i] and i
int x = i;
int y = host[i];
int takenew, leavenew;
if (protocol[i]==0){
//iamyourfriend
takenew = take[y]+leave[x];
leavenew = max(leave[x]+leave[y], take[x]+leave[y]);
} else if (protocol[i]==1){
//myfriendsareyourfriends
takenew = max(take[x]+take[y], max(take[x]+leave[y], leave[x]+take[y]));
leavenew = leave[x]+leave[y];
} else {
//weareyourfriends
takenew = max(take[x]+leave[y],take[y]+leave[x]);
leavenew = leave[x]+leave[y];
}
take[host[i]] = takenew;
leave[host[i]] = leavenew;
}
return max(take[0],leave[0]);
}
# | 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... |