# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
260448 | dolphingarlic | Political Development (BOI17_politicaldevelopment) | C++14 | 1864 ms | 24568 KiB |
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>
typedef long long ll;
using namespace std;
set<int> graph[50000];
bool tried[50000];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, k;
cin >> n >> k;
queue<int> q;
for (int i = 0; i < n; i++) {
int s;
cin >> s;
if (s < k) {
tried[i] = true;
q.push(i);
}
while (s--) {
int b;
cin >> b;
graph[i].insert(b);
}
}
int ans = 0;
while (q.size()) {
int curr = q.front();
q.pop();
for (int i = 0; i < (1 << graph[curr].size()); i++) {
if (__builtin_popcount(i) <= ans) continue;
vector<int> adj;
int tmp = i;
for (int j : graph[curr]) {
if (tmp & 1) adj.push_back(j);
tmp >>= 1;
}
bool good = true;
for (int j = 0; j < adj.size(); j++) {
for (int l = j + 1; l < adj.size(); l++) {
good &= graph[adj[j]].find(adj[l]) != graph[adj[j]].end();
}
}
if (good) ans = __builtin_popcount(i);
}
for (int i : graph[curr]) {
graph[i].erase(curr);
if (!tried[i] && graph[i].size() < k) {
tried[i] = true;
q.push(i);
}
}
graph[curr].clear();
}
cout << ans + 1;
return 0;
}
Compilation message (stderr)
# | 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... |