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;
int p[100009], q[100009];
int findSample (int N, int confidence[], int host[], int protocol[])
{
for (int i=0; i<N; i++)
p[i] = confidence[i], q[i] = 0;
for (int i=N - 1; i>0; i--)
{
int j = host[i], oldP = p[j], oldQ = q[j];
if (protocol[i] == 0)
p[j] = oldP + q[i],
q[j] = oldQ + max (p[i], q[i]);
else
if (protocol[i] == 1)
p[j] = max ({oldP + p[i], oldP + q[i], oldQ + p[i]}),
q[j] = oldQ + q[i];
else
p[j] = max (oldP + q[i], oldQ + p[i]),
q[j] = oldQ + q[i];
}
return max (p[0], q[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... |