#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
#define f first
#define s second
#define MOD 1000000007
#define LOGN 20
#define MAXN 200005
vector<set<int>> graph;
vector<pair<int,int>> degree;
int main() {
fast
int N, K, x, D;
cin >> N >> K;
graph = vector<set<int>>(N, set<int>());
degree = vector<pair<int,int>>(N);
for (int i = 0; i < N; i++)
degree[i] = {0, i};
for (int i = 0; i < N; i++) {
cin >> D;
for (int j = 0; j < D; j++) {
cin >> x;
graph[x].insert(i);
graph[i].insert(x);
degree[i].f++;
degree[x].f++;
}
}
sort(degree.begin(), degree.end());
int ans = 1;
for (auto u : degree) {
int node = u.s;
int degree = graph[node].size();
vector<int> adj;
for (auto u : graph[node])
adj.push_back(u);
int mx_mask = (1<<degree) - 1;
for (int msk = 1; msk <= mx_mask; msk++) {
if (__builtin_popcount(msk) <= ans)
continue;
vector<int> taken;
taken.push_back(node);
bool check = true;
for (int j = 0; j < degree; j++) {
if ((1<<j) & msk) {
for (auto u : taken) {
if (graph[adj[j]].count(u) == 0)
check = false;
}
taken.push_back(adj[j]);
}
}
if (check)
ans = max(ans, (int)taken.size());
}
for (auto u : graph[node])
graph[u].erase(node);
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
596 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
256 KB |
Output is correct |
8 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |