# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
131545 | Mahdi_Jfri | Friend (IOI14_friend) | C++14 | 38 ms | 4216 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];
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;
adj[host[i]].pb(i);
is[i] = (pt[i] == 0);
}
for(int i = 0; i < n; i++)
dp[i][1] = a[i] = A[i];
for(int u = n - 1; u > 0; u--)
{
int v = host[u];
int tmp[2] = {0 , 0};
for(int x = 0; x < 2; x++)
for(int y = 0; y < 2; y++)
{
if(x && y && pt[u] != 1)
continue;
if(pt[u])
tmp[x | y] = max(tmp[x | y] , dp[v][x] + dp[u][y]);
else
tmp[x] = max(tmp[x] , dp[v][x] + dp[u][y]);
}
dp[v][0] = tmp[0] , dp[v][1] = tmp[1];
}
return max(dp[0][1] , dp[0][0]);
}
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... |