# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
404168 | 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[2][MAXN];
int v[MAXN];
vector<int> ar[MAXN];
int getDP(int cur, int p);
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);
return max(getDP(0, 0), getDP(0, 1));
}
int getDP(int cur, int p){
if(dp[cur][p] != -1) return dp[cur][p];
dp[cur][p] = 0;
for(int i = 0; i < ar[cur].size(); i++){
int viz = ar[cur][i];
dp[cur][p] += getDP(viz, !p);
dp[cur][p] += (!p) * getDP(viz, p);
}
dp[cur][p] += v[cur] * p;
return dp[cur][p];
}
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... |