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;
const int nax = 1000;
vector<int>g[nax];
int a[nax];
long long dp[nax][2];
long long dfs(int v, int perm) {
long long &ret = dp[v][perm];
if(ret!=-1) return ret;
ret = 0;
for(int u : g[v]) {
ret += dfs(u, 1);
}
if(perm) {
long long an = a[v];
for(int u : g[v]) {
an += dfs(u, 0);
}
ret = max(ret, an);
}
return ret;
}
int findSample(int n,int confidence[],int host[],int protocol[]){
for(int i=0; i<n; ++i) {
a[i] = confidence[i];
}
for(int i=1; i<n; ++i) {
g[host[i]].push_back(i);
}
memset(dp, -1, sizeof dp);
return dfs(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... |