# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
424220 | Charis02 | Friend (IOI14_friend) | C++14 | 1 ms | 460 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<iostream>
#include<vector>
#include<string.h>
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 1004
using namespace std;
vector < int > graph[N];
int conf[N];
int dp[N][2];
int calc(int cur,int par,int choose)
{
int res = 0;
if(dp[cur][choose]!=-1)
return dp[cur][choose];
if(choose)
{
res = conf[cur];
rep(i,0,graph[cur].size())
{
int v = graph[cur][i];
if(v == par)
continue;
res += calc(v,cur,0);
}
}
else
{
rep(i,0,graph[cur].size())
{
int v = graph[cur][i];
if(v == par)
continue;
res += max(calc(v,cur,0),calc(v,cur,1));
}
}
return dp[cur][choose] = res;
}
int findSample(int n,int confidence[],int host[],int protocol[])
{
rep(i,0,n)
{
conf[i] = confidence[i];
if(i == 0)
continue;
graph[host[i]].push_back(i);
graph[i].push_back(host[i]);
}
memset(dp,-1,sizeof dp);
return max(calc(1,1,0),calc(1,1,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... |