This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "friend.h"
#include <vector>
using namespace std;
int findSample(int n,int confidence[],int host[],int protocol[]){
vector<int> Yes(n, 0), No(n, 0);
for(int i = 0; i < n; i++) Yes[i] += confidence[i];
for(int i = n-1; i >= 1; i--){
if(protocol[i] == 0) {
Yes[ host[i] ] += No[i];
No[ host[i] ] += max(Yes[i], No[i]);
}
else if(protocol[i] == 1){
Yes[ host[i] ] = max(Yes[ host[i] ] + max(Yes[i], No[i]), No[ host[i] ] + Yes[i]);
No[ host[i] ] += No[i];
}
else{
Yes[ host[i] ] = max(Yes[ host[i] ] + No[i], No[ host[i] ] + Yes[i]);
No[ host[i] ] += No[i];
}
}
return max(Yes[0], No[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... |