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>
#define fi first
#define se second
#define eb emplace_back
#define em emplace
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int MAX = 101010;
const int INF = INT_MAX >> 1;
const ll LINF = LLONG_MAX >> 1;
const ll mod = 1e9+9;
pii arr[MAX];
int findSample(int n,int c[],int h[],int p[]){
for(int i = 0; i < n; i++) {
arr[i].fi = c[i];
}
for(int i = n - 1; i > 0; i--) {
if(p[i] == 2) {
arr[h[i]].fi = max(arr[h[i]].fi + arr[i].se, arr[h[i]].se + arr[i].fi);
arr[h[i]].se = arr[h[i]].se + arr[i].se;
}
if(p[i] == 1) {
arr[h[i]].fi = max({
arr[h[i]].fi + arr[i].se,
arr[h[i]].se + arr[i].fi,
arr[h[i]].fi + arr[i].fi
});
arr[h[i]].se = arr[h[i]].se + arr[i].se;
}
if(p[i] == 0) {
arr[h[i]].fi += arr[i].se;
arr[h[i]].se += max(arr[i].se, arr[i].fi);
}
}
return max(arr[0].fi, arr[0].se);
}
# | 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... |