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 <bits/stdc++.h>
#define ii pair<int, int>
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vii vector< pair<int, int> >
typedef long long ll;
using namespace std;
int Host[100005];
int Prot[100005];
int conf[100005];
int c[100005];
int nc[100005];
int findSample(int n, int *conf, int *Host, int *Prot)
{
for(int i = 0; i< n; i++) c[i] = conf[i];
for(int i = n-1; i>= 1; i--)
{
int x = Host[i];
if(Prot[i] == 1)
{
c[x] = max(max(c[x]+nc[i], c[i]+nc[x]), c[i]+c[x]);
nc[x] = nc[x] + nc[i];
}
else if(Prot[i] == 2)
{
c[x] = max(c[x]+nc[i], c[i]+nc[x]);
nc[x] = nc[x]+nc[i];
}
else
{
c[x] = c[x]+nc[i];
nc[x] = max(c[i]+nc[x], nc[i]+nc[x]);
}
}
return max(c[0], nc[0]);
return 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... |