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;
typedef long long ll;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef complex<ld> point;
void debug_out(){cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
cout << H << ' ';
debug_out(T...);
}
#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)
const int maxn = 1e5 + 10;
int dp[maxn][2];
// Find out best sample
int findSample(int n,int w[],int p[],int t[]){
for (int i = 0; i < n; i++){
dp[i][1] = w[i];
}
for (int i = n-1; i; i--){
if (t[i] == 0){
dp[p[i]][0] += max(dp[i][0], dp[i][1]);
dp[p[i]][1] += dp[i][0];
}
else if (t[i] == 1){
dp[p[i]][1] = max({dp[p[i]][1] + dp[i][1], dp[p[i]][1] + dp[i][0] , dp[p[i]][0] + dp[i][1]});
dp[p[i]][0] += dp[i][0];
}
else{
dp[p[i]][1] = max(dp[i][1] + dp[p[i]][0], dp[p[i]][1] + dp[i][0]);
dp[p[i]][0] += dp[i][0];
}
}
return max(dp[0][0], dp[0][1]);
}
# | 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... |