# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
131412 | Mahdi_Jfri | Friend (IOI14_friend) | C++14 | 3 ms | 380 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 ll long long
#define pb push_back
const int maxn = 1e3 + 20;
vector<int> adj[maxn] , adj2[maxn];
int dp[maxn][2] , a[maxn];
bool is[maxn];
void plant(int v)
{
dp[v][1] = a[v];
for(auto u : adj[v])
{
plant(u);
dp[v][0] += dp[u][1];
dp[v][1] += dp[u][0];
}
dp[v][1] = max(dp[v][1] , dp[v][0]);
}
int findSample(int n,int a[],int host[],int pt[])
{
bool has[3] = {0 , 0 , 0};
for(int i = 1; i < n; i++)
{
has[pt[i]] = 1;
if(pt[i] == 0)
adj[host[i]].pb(i);
else
adj2[host[i]].pb(i);
is[i] = (pt[i] == 2);
}
pt[0] = 1;
for(int i = 0; i < n; i++)
if(!i || pt[i])
plant(i);
return 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... |