Submission #811032

#TimeUsernameProblemLanguageResultExecution timeMemory
811032tch1cherinPolitical Development (BOI17_politicaldevelopment)C++17
77 / 100
3063 ms26404 KiB
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(nullptr)->sync_with_stdio(false); int N, K; cin >> N >> K; vector<set<int>> graph(N); set<pair<int, int>> nodes; for (int node = 0; node < N; node++) { int degree; cin >> degree; nodes.emplace(degree, node); for (int j = 0; j < degree; j++) { int neighbour; cin >> neighbour; graph[node].insert(neighbour); } } vector<int> to(N, -1); int answer = 0; while (!nodes.empty()) { auto [degree, node] = *nodes.begin(); nodes.erase({degree, node}); vector<int> neighbours; to[node] = 0; for (int i = 0; i < degree; i++) { int neighbour = *graph[node].begin(); nodes.erase({(int)graph[neighbour].size(), neighbour}); graph[node].erase(neighbour); graph[neighbour].erase(node); nodes.emplace((int)graph[neighbour].size(), neighbour); to[neighbour] = 1 + i; neighbours.push_back(neighbour); } vector<int16_t> small_graph(degree + 1); small_graph[to[node]] = (1 << (degree + 1)) - 1; for (int x : neighbours) { small_graph[to[x]] |= 1 << to[x]; small_graph[to[x]] |= 1 << to[node]; for (int y : graph[x]) { if (to[y] != -1) { small_graph[to[x]] |= 1 << to[y]; } } } for (int clique = 0; clique < (1 << degree); clique++) { int16_t intersection = small_graph[to[node]]; for (int vertex = 1; vertex < degree + 1; vertex++) { if ((clique >> (vertex - 1)) & 1) { intersection &= small_graph[vertex]; } } if (((clique << 1) | 1) == intersection) { answer = max(answer, __builtin_popcount(intersection)); } } to[node] = -1; for (int neighbour : neighbours) { to[neighbour] = -1; } } cout << answer << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...