# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
430629 | Rouge_Hugo | Friend (IOI14_friend) | C++14 | 3 ms | 588 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>
#define ll long long
#define fi first
#define se second
#define pb push_back
using namespace std;
const int N=1009;
vector<int>v[N];
int vis[N][2],a[N];
int dfs(int x,int p)
{
vis[x][1]=a[x];
for(auto it:v[x])
{
if(it==p)continue;
dfs(it,x);
vis[x][0]+=vis[it][1];
vis[x][1]+=vis[it][0];
}
vis[x][1]=max(vis[x][1],vis[x][0]);
}
int findSample(int n,int c[],int h[],int p[]){
for(int i=1;i<n;i++)
{
v[h[i]].pb(i);
v[i].pb(h[i]);
}
for(int i=0;i<n;i++)a[i]=c[i];
dfs(0,0);
vis[0][0]=max(vis[0][0],vis[0][1]);
return vis[0][0];
}
/*
5
1 100 1 1 100
0 0
0 0
1 1
2 2
*/
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... |