# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
404171 | peuch | 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 = 1e3 + 10;
int dp[MAXN][2];
int v[MAXN];
vector<int> ar[MAXN];
void dfs(int cur);
int findSample(int n,int confidence[],int host[],int protocol[]){
memset(dp, -1, sizeof(dp));
for(int i = 0; i < n; i++)
v[i] = confidence[i];
for(int i = 1; i < n; i++)
ar[host[i]].push_back(i);
dfs(0);
return dp[0][1];
}
void dfs(int cur){
dp[cur][0] = 0;
dp[cur][1] = v[cur];
for(int i = 0; i < ar[cur].size(); i++){
int viz = ar[cur][i];
dfs(viz);
dp[cur][0] += dp[viz][1];
dp[cur][1] += dp[viz][0];
}
dp[cur][1] = max(dp[cur][1], dp[cur][0]);
}
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... |