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 <bits/stdc++.h>
#include "friend.h"
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 10;
vector < int > adj[MAXN];
int findSample(int n, int c[], int p[], int type[])
{
for(int i = 1; i < n; i++)
{
if(type[i] == 0)
{
adj[i].push_back(p[i]);
adj[p[i]].push_back(i);
}
else if(type[i] == 1)
{
for(int v : adj[p[i]])
{
adj[v].push_back(i);
adj[i].push_back(v);
}
}
else if(type[i] == 2)
{
for(int v : adj[p[i]])
{
adj[v].push_back(i);
adj[i].push_back(v);
}
adj[i].push_back(p[i]);
adj[p[i]].push_back(i);
}
}
int ans = 0;
for(int mask = 1; mask < (1 << n); mask++)
{
bool lampa = false;
for(int i = 0; i < n; i++)
{
if(mask & (1 << i))
{
for(int v : adj[i])
{
if(mask & (1 << v))
lampa = true;
}
}
}
if(lampa)
continue;
int sum = 0;
for(int i = 0; i < n; i++)
{
if(mask & (1 << i))
sum += c[i];
}
ans = max(ans, sum);
}
return ans;
}
# | 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... |