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;
const int N = 1003;
int n;
int a[N];
bool g[N][N];
vector<int> f[N];
int findSample(int n_, int confidence[],int host[],int protocol[]){
n = n_;
for (int i = 0; i < n; ++i) {
a[i] = confidence[i];
}
for (int i = 1; i < n; ++i) {
if (protocol[i] == 0) {
g[host[i]][i] = true;
g[i][host[i]] = true;
f[host[i]].push_back(i);
f[i].push_back(host[i]);
}
else {
for (int j : f[host[i]]) {
g[j][i] = true;
g[i][j] = true;
f[j].push_back(i);
f[i].push_back(j);
}
if (protocol[i] == 2) {
g[i][host[i]] = true;
g[host[i]][i] = true;
f[host[i]].push_back(i);
f[i].push_back(host[i]);
}
}
}
int ans = 0;
for (int i = 0; i < (1 << n); ++i) {
int tmp = 0;
for (int j = 0; j < n; ++j) {
if (!(i >> j & 1)) {
continue;
}
tmp += a[j];
for (int k = j + 1; k < n; ++k) {
if (!(i >> k & 1)) {
continue;
}
if (g[j][k]) {
tmp = -INT_MAX;
break;
}
}
}
ans = max(ans, tmp);
}
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... |