이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 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... |