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 <bits/stdc++.h>
using namespace std;
struct state{
int p, q;
};
state st[100011];
state f(int ptc, state s, state t){
if(ptc == 0) return {s.p + t.q, max(s.q + t.p, s.q + t.q)};
else if(ptc == 1) return {max(s.p + t.p, max(s.p + t.q, s.q + t.p)), s.q + t.q};
else return {max(s.p + t.q, s.q + t.p), s.q + t.q};
}
int findSample(int n, int confidence[], int host[], int protocol[]){
for(int i = 0; i < n; i++) st[i] = {confidence[i], 0};
for(int i = n - 1; i >= 1; i--){
st[host[i]] = f(protocol[i], st[host[i]], st[i]);
}
return max(st[0].p, st[0].q);
}
# | 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... |