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;
#define pb push_back
#define sz(s) (int)s.size()
const int N = (int)1e5 + 7;
const int smN = (int)1e3 + 7;
vector < int > gr[N];
int has[smN][smN];
void addedge(int a, int b) {
gr[a].pb(b);
gr[b].pb(a);
has[a][b] = has[b][a] = 1;
}
int findSample(int n, int confidence[], int host[], int protocol[]){
int ans = 0;
for (int i = 1; i < n; i++) {
if (protocol[i] == 0 || protocol[i] == 2) {
addedge(host[i], i);
}
if (protocol[i] == 1 || protocol[i] == 2) {
for (int to : gr[host[i]]) {
addedge(to, i);
}
}
}
for (int mask = 0; mask < (1 << n); mask++) {
vector < int > v;
for (int i = 0; i < n; i++) {
if (mask & (1 << i)) {
v.pb(i);
}
}
int res = 0;
bool ok = 1;
for (int i = 0; i < sz(v) && ok; i++) {
for (int j = i + 1; j < sz(v) && ok; j++) {
if (has[v[i]][v[j]]) {
ok = 0;
}
}
}
if (ok) {
for (int to : v) {
res += confidence[to];
}
}
ans = max(ans, res);
}
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... |