# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
587120 | hibiki | Friend (IOI14_friend) | C++11 | 1 ms | 340 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;
#define pb push_back
// Find out best sample
int ans = 0;
int con[1005];
vector<int> v[1005];
int dp[1005][2];
void dfs(int nw, int fa)
{
dp[nw][0] = 0;
dp[nw][1] = con[nw];
for(auto go: v[nw])
{
if(go == fa) continue;
dfs(go, nw);
dp[nw][0] = max(dp[go][0], dp[go][1]);
dp[nw][1] += dp[go][0];
}
}
int findSample(int n,int c[],int h[],int p[]){
int ty;
for(int i = 0; i < n; i++)
con[i] = c[i];
for(int i = 1; i < n; i++)
ty = p[i];
// if(n < 20) ty = 3;
if(ty == 0)
{
for(int i = 1; i < n; i++)
v[h[i]].pb(i), v[i].pb(h[i]);
dfs(0, -1);
ans = max(dp[0][0], dp[0][1]);
}
else if(ty == 1)
{
for(int i = 0; i < n; i++)
ans += c[i];
}
else if(ty == 2)
{
for(int i = 0; i < n; i++)
ans = max(ans, c[i]);
}
else
{
}
return ans;
}
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... |