# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
748246 | kkkkkkkk | Friend (IOI14_friend) | C++14 | 1 ms | 468 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 <bits/stdc++.h>
using namespace std;
int *C;
vector<int> nivo_teminja[1005];
int dlabocina_na_teme[1005],najg_dlab;
int dp[1005][2];
vector<int> G[1005];
void f(int teme) {
if (dlabocina_na_teme[teme]==najg_dlab) {
dp[teme][0]=C[teme];
dp[teme][1]=0;
}
dp[teme][0]=C[teme];
for (int i=0;i<G[teme].size();i++){
int child=G[teme][i];
f(child);
dp[teme][0]+=dp[child][1];
dp[teme][1]+=max(dp[child][0],dp[child][1]);
}
}
int findSample(int n,int confidence[],int host[],int protocol[]) {
C=confidence;
nivo_teminja[0].push_back(0);
dlabocina_na_teme[0]=0;
for (int i=1;i<n;i++) {
G[host[i]].push_back(i);
int nivo_parent=dlabocina_na_teme[host[i]];
dlabocina_na_teme[i]=nivo_parent+1;
nivo_teminja[dlabocina_na_teme[i]].push_back(i);
najg_dlab=max(najg_dlab,dlabocina_na_teme[i]);
}
f(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... |