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>
using namespace std;
int findSample(int n, int confidence[], int host[], int protocol[]) {
vector<vector<int>> adj(n, vector<int>(n, 0));
for (int i = 1; i < n; ++i) {
if (protocol[i] == 0 || protocol[i] == 2)
adj[host[i]][i] = adj[i][host[i]] = 1;
if (protocol[i] == 1 || protocol[i] == 2) {
for (int j = 0; j < n; ++j) {
if (adj[j][host[i]]) adj[i][j] = adj[j][i] = 1;
}
}
}
int ans = 0;
vector<int> c((1<<n), 0);
queue<int> q;
q.push(0);
while (!q.empty()) {
int mask = q.front();
q.pop();
for (int i = 0; i < n; ++i) {
if (mask&(1<<i)) continue;
bool ok = true;
for (int j = 0; j < n && ok; ++j) {
if (j == i) continue;
if (mask&(1<<j) && adj[i][j]) ok = false;
}
if (ok) {
c[mask|(1<<i)] = c[mask]+confidence[i];
ans = max(ans, c[mask|(1<<i)]);
q.push(mask|(1<<i));
}
}
}
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... |