#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<vector<int>> graph;
vector<pair<int,int>> degree;
set<pair<int,int>> edges;
bool omit[MAXN];
int main() {
fast
int N, K, x, D;
cin >> N >> K;
graph = vector<vector<int>>(N, vector<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].push_back(i);
graph[i].push_back(x);
edges.insert({min(x, i), max(x, i)});
degree[i].f++;
degree[x].f++;
}
}
sort(degree.begin(), degree.end());
int ans = 1;
for (auto u : degree) {
int node = u.s;
vector<int> adj;
for (auto p : graph[node]) {
if (!omit[p])
adj.push_back(p);
}
int degree = adj.size();
int mx_mask = (1<<degree) - 1;
for (int msk = 1; msk <= mx_mask; msk++) {
int k = __builtin_popcount(msk);
if (k + 1 <= 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 (edges.find({min(adj[j], u), max(adj[j], u)}) == edges.end())
check = false;
}
taken.push_back(adj[j]);
}
}
if (check)
ans = max(ans, k + 1);
}
}
cout << ans << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Execution timed out |
3059 ms |
852 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Execution timed out |
3059 ms |
852 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
7 ms |
212 KB |
Output is correct |
3 |
Correct |
8 ms |
328 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
6 ms |
328 KB |
Output is correct |
6 |
Correct |
6 ms |
212 KB |
Output is correct |
7 |
Correct |
6 ms |
224 KB |
Output is correct |
8 |
Correct |
7 ms |
212 KB |
Output is correct |
9 |
Correct |
6 ms |
212 KB |
Output is correct |
10 |
Correct |
7 ms |
212 KB |
Output is correct |
11 |
Execution timed out |
3014 ms |
23564 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Execution timed out |
3059 ms |
852 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Execution timed out |
3059 ms |
852 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |