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 findSample(int n,int c[],int h[],int t[]){
vector<int> p(n, 0), q(n, 0);
for (int i = 0; i < n; i++) p[i] = c[i];
for (int i = n - 1; i > 0; i--)
{
if (t[i] == 0) // i am your friend
{
p[h[i]] = p[h[i]] + q[i];
q[h[i]] = max(q[h[i]] + q[i], q[h[i]] + p[i]);
}
if (t[i] == 1) // my friends are your friends
{
p[h[i]] = max({p[h[i]] + p[i], q[h[i]] + p[i], p[h[i]] + q[i]});
q[h[i]] = q[h[i]] + q[i];
}
if (t[i] == 2) // we are your friends
{
p[h[i]] = max(p[h[i]] + q[i], q[h[i]] + p[i]);
q[h[i]] = q[h[i]] + q[i];
}
p[h[i]] = max(p[h[i]], q[h[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... |