# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
404160 | ly20 | Friend (IOI14_friend) | C++17 | 1 ms | 332 KiB |
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 MAXN = 1123;
int val[MAXN];
vector <int> grafo[MAXN];
// Find out best sample
int dp[MAXN][2];
void dfs(int v, int p) {
dp[v][0] = 0; dp[v][1] = val[v];
for(int i = 0; i < grafo[v].size(); i++) {
int viz = grafo[v][i];
if(viz == p) continue;
dfs(viz, v);
dp[v][0] += max(dp[viz][0], dp[viz][1]);
dp[v][1] += dp[viz][0];
}
}
int findSample(int n,int confidence[],int host[],int protocol[]){
int tot = 0;
int mx = 0;
for(int i = 0; i < n; i++) {
val[i] = confidence[i];
}
for(int i = 1; i < n - 1; i++) {
int cur = host[i];
grafo[i].push_back(cur);
grafo[cur].push_back(i);
}
dfs(0, 0);
return max(dp[0][0], dp[0][1]);
}
Compilation message (stderr)
# | 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... |