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>
#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
using namespace std;
const int N = 15;
vector <int> g[N], vec;
int u[N], dp[1 << 15], ans, sum;
int findSample(int n, int val[], int batya[], int type[]) {
for (int i = 1; i < n; i++) {
if (type[i] == 0) {
g[batya[i]].pb(i);
g[i].pb(batya[i]);
}
else if (type[i] == 1) {
for (auto it: g[batya[i]]) {
g[i].pb(it);
g[it].pb(i);
}
}
else {
g[batya[i]].pb(i);
g[i].pb(batya[i]);
for (auto it: g[batya[i]]) {
g[i].pb(it);
g[it].pb(i);
}
}
}
for (int mask = 0; mask < (1 << n); mask++) {
memset(u, 0, sizeof(u));
sum = 0;
for (int j = 0; j < n; j++) {
if (mask>>j&1)
u[j] = 1, sum += val[j];
}
bool fl = 1;
for (int j = 0; j < n; j++) {
if (u[j] == 0) continue;
for (auto to : g[j]) {
if (u[to])
fl = 0;
}
}
if (fl)
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... |