#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[i].insert(x);
degree[i].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++) {
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 (graph[adj[j]].count(u) == 0)
check = false;
}
taken.push_back(adj[j]);
}
}
if (check)
ans = max(ans, k + 1);
}
for (auto u : graph[node])
graph[u].erase(node);
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
4 ms |
980 KB |
Output is correct |
4 |
Correct |
3 ms |
980 KB |
Output is correct |
5 |
Correct |
2 ms |
980 KB |
Output is correct |
6 |
Correct |
3 ms |
980 KB |
Output is correct |
7 |
Correct |
2 ms |
980 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
4 ms |
980 KB |
Output is correct |
4 |
Correct |
3 ms |
980 KB |
Output is correct |
5 |
Correct |
2 ms |
980 KB |
Output is correct |
6 |
Correct |
3 ms |
980 KB |
Output is correct |
7 |
Correct |
2 ms |
980 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
3 ms |
980 KB |
Output is correct |
12 |
Correct |
2 ms |
980 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
2 ms |
980 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
3 ms |
980 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
3 ms |
980 KB |
Output is correct |
19 |
Correct |
1 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
724 KB |
Output is correct |
21 |
Correct |
2 ms |
724 KB |
Output is correct |
22 |
Correct |
1 ms |
620 KB |
Output is correct |
23 |
Correct |
3 ms |
1108 KB |
Output is correct |
24 |
Correct |
1 ms |
596 KB |
Output is correct |
25 |
Correct |
3 ms |
1108 KB |
Output is correct |
26 |
Correct |
5 ms |
1108 KB |
Output is correct |
27 |
Correct |
2 ms |
980 KB |
Output is correct |
28 |
Correct |
3 ms |
1108 KB |
Output is correct |
29 |
Correct |
2 ms |
980 KB |
Output is correct |
30 |
Correct |
3 ms |
1108 KB |
Output is correct |
31 |
Correct |
4 ms |
1108 KB |
Output is correct |
32 |
Correct |
5 ms |
1108 KB |
Output is correct |
33 |
Correct |
3 ms |
1108 KB |
Output is correct |
34 |
Correct |
3 ms |
1108 KB |
Output is correct |
35 |
Correct |
2 ms |
724 KB |
Output is correct |
36 |
Correct |
2 ms |
724 KB |
Output is correct |
37 |
Correct |
2 ms |
724 KB |
Output is correct |
38 |
Correct |
1 ms |
596 KB |
Output is correct |
39 |
Correct |
2 ms |
596 KB |
Output is correct |
40 |
Correct |
7 ms |
1492 KB |
Output is correct |
41 |
Correct |
2 ms |
596 KB |
Output is correct |
42 |
Correct |
5 ms |
1492 KB |
Output is correct |
43 |
Correct |
5 ms |
1492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
596 KB |
Output is correct |
2 |
Correct |
0 ms |
324 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 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 |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1109 ms |
24188 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
240 ms |
24076 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1150 ms |
24188 KB |
Output is correct |
16 |
Correct |
269 ms |
24188 KB |
Output is correct |
17 |
Correct |
650 ms |
24268 KB |
Output is correct |
18 |
Correct |
837 ms |
24184 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
4 ms |
980 KB |
Output is correct |
4 |
Correct |
3 ms |
980 KB |
Output is correct |
5 |
Correct |
2 ms |
980 KB |
Output is correct |
6 |
Correct |
3 ms |
980 KB |
Output is correct |
7 |
Correct |
2 ms |
980 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
3 ms |
980 KB |
Output is correct |
12 |
Correct |
2 ms |
980 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
2 ms |
980 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
3 ms |
980 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
3 ms |
980 KB |
Output is correct |
19 |
Correct |
1 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
724 KB |
Output is correct |
21 |
Correct |
2 ms |
724 KB |
Output is correct |
22 |
Correct |
1 ms |
620 KB |
Output is correct |
23 |
Correct |
3 ms |
1108 KB |
Output is correct |
24 |
Correct |
1 ms |
596 KB |
Output is correct |
25 |
Correct |
3 ms |
1108 KB |
Output is correct |
26 |
Correct |
5 ms |
1108 KB |
Output is correct |
27 |
Correct |
2 ms |
980 KB |
Output is correct |
28 |
Correct |
3 ms |
1108 KB |
Output is correct |
29 |
Correct |
2 ms |
980 KB |
Output is correct |
30 |
Correct |
3 ms |
1108 KB |
Output is correct |
31 |
Correct |
4 ms |
1108 KB |
Output is correct |
32 |
Correct |
5 ms |
1108 KB |
Output is correct |
33 |
Correct |
3 ms |
1108 KB |
Output is correct |
34 |
Correct |
3 ms |
1108 KB |
Output is correct |
35 |
Correct |
2 ms |
724 KB |
Output is correct |
36 |
Correct |
2 ms |
724 KB |
Output is correct |
37 |
Correct |
2 ms |
724 KB |
Output is correct |
38 |
Correct |
1 ms |
596 KB |
Output is correct |
39 |
Correct |
2 ms |
596 KB |
Output is correct |
40 |
Correct |
7 ms |
1492 KB |
Output is correct |
41 |
Correct |
2 ms |
596 KB |
Output is correct |
42 |
Correct |
5 ms |
1492 KB |
Output is correct |
43 |
Correct |
5 ms |
1492 KB |
Output is correct |
44 |
Correct |
8 ms |
2388 KB |
Output is correct |
45 |
Correct |
0 ms |
212 KB |
Output is correct |
46 |
Correct |
5 ms |
1492 KB |
Output is correct |
47 |
Correct |
25 ms |
2388 KB |
Output is correct |
48 |
Correct |
5 ms |
1616 KB |
Output is correct |
49 |
Correct |
28 ms |
2388 KB |
Output is correct |
50 |
Correct |
42 ms |
2388 KB |
Output is correct |
51 |
Correct |
2486 ms |
4308 KB |
Output is correct |
52 |
Correct |
3 ms |
980 KB |
Output is correct |
53 |
Correct |
667 ms |
4696 KB |
Output is correct |
54 |
Execution timed out |
3051 ms |
4820 KB |
Time limit exceeded |
55 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
4 ms |
980 KB |
Output is correct |
4 |
Correct |
3 ms |
980 KB |
Output is correct |
5 |
Correct |
2 ms |
980 KB |
Output is correct |
6 |
Correct |
3 ms |
980 KB |
Output is correct |
7 |
Correct |
2 ms |
980 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
3 ms |
980 KB |
Output is correct |
12 |
Correct |
2 ms |
980 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
2 ms |
980 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
3 ms |
980 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
3 ms |
980 KB |
Output is correct |
19 |
Correct |
1 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
724 KB |
Output is correct |
21 |
Correct |
2 ms |
724 KB |
Output is correct |
22 |
Correct |
1 ms |
620 KB |
Output is correct |
23 |
Correct |
3 ms |
1108 KB |
Output is correct |
24 |
Correct |
1 ms |
596 KB |
Output is correct |
25 |
Correct |
3 ms |
1108 KB |
Output is correct |
26 |
Correct |
5 ms |
1108 KB |
Output is correct |
27 |
Correct |
2 ms |
980 KB |
Output is correct |
28 |
Correct |
3 ms |
1108 KB |
Output is correct |
29 |
Correct |
2 ms |
980 KB |
Output is correct |
30 |
Correct |
3 ms |
1108 KB |
Output is correct |
31 |
Correct |
4 ms |
1108 KB |
Output is correct |
32 |
Correct |
5 ms |
1108 KB |
Output is correct |
33 |
Correct |
3 ms |
1108 KB |
Output is correct |
34 |
Correct |
3 ms |
1108 KB |
Output is correct |
35 |
Correct |
2 ms |
724 KB |
Output is correct |
36 |
Correct |
2 ms |
724 KB |
Output is correct |
37 |
Correct |
2 ms |
724 KB |
Output is correct |
38 |
Correct |
1 ms |
596 KB |
Output is correct |
39 |
Correct |
2 ms |
596 KB |
Output is correct |
40 |
Correct |
7 ms |
1492 KB |
Output is correct |
41 |
Correct |
2 ms |
596 KB |
Output is correct |
42 |
Correct |
5 ms |
1492 KB |
Output is correct |
43 |
Correct |
5 ms |
1492 KB |
Output is correct |
44 |
Correct |
0 ms |
212 KB |
Output is correct |
45 |
Correct |
118 ms |
17148 KB |
Output is correct |
46 |
Correct |
34 ms |
10068 KB |
Output is correct |
47 |
Correct |
121 ms |
17160 KB |
Output is correct |
48 |
Correct |
111 ms |
17100 KB |
Output is correct |
49 |
Correct |
24 ms |
7636 KB |
Output is correct |
50 |
Correct |
165 ms |
21708 KB |
Output is correct |
51 |
Correct |
125 ms |
17100 KB |
Output is correct |
52 |
Correct |
27 ms |
7764 KB |
Output is correct |
53 |
Correct |
25 ms |
7764 KB |
Output is correct |
54 |
Correct |
4 ms |
3028 KB |
Output is correct |
55 |
Correct |
169 ms |
21836 KB |
Output is correct |
56 |
Correct |
13 ms |
5332 KB |
Output is correct |
57 |
Correct |
27 ms |
7764 KB |
Output is correct |
58 |
Correct |
28 ms |
10068 KB |
Output is correct |
59 |
Correct |
12 ms |
5332 KB |
Output is correct |
60 |
Correct |
12 ms |
5332 KB |
Output is correct |
61 |
Correct |
28 ms |
10020 KB |
Output is correct |
62 |
Correct |
19 ms |
7764 KB |
Output is correct |
63 |
Correct |
46 ms |
11280 KB |
Output is correct |
64 |
Correct |
11 ms |
5332 KB |
Output is correct |
65 |
Correct |
63 ms |
13516 KB |
Output is correct |
66 |
Correct |
21 ms |
7764 KB |
Output is correct |
67 |
Correct |
44 ms |
11220 KB |
Output is correct |
68 |
Correct |
51 ms |
13004 KB |
Output is correct |
69 |
Correct |
53 ms |
13516 KB |
Output is correct |
70 |
Correct |
20 ms |
7736 KB |
Output is correct |
71 |
Correct |
55 ms |
13052 KB |
Output is correct |
72 |
Correct |
42 ms |
10836 KB |
Output is correct |
73 |
Correct |
98 ms |
15052 KB |
Output is correct |
74 |
Correct |
22 ms |
7764 KB |
Output is correct |
75 |
Correct |
28 ms |
6228 KB |
Output is correct |
76 |
Correct |
50 ms |
10836 KB |
Output is correct |
77 |
Correct |
99 ms |
15116 KB |
Output is correct |
78 |
Correct |
50 ms |
7636 KB |
Output is correct |
79 |
Correct |
26 ms |
6228 KB |
Output is correct |
80 |
Correct |
12 ms |
3284 KB |
Output is correct |
81 |
Correct |
44 ms |
7628 KB |
Output is correct |
82 |
Correct |
52 ms |
12372 KB |
Output is correct |
83 |
Correct |
12 ms |
3284 KB |
Output is correct |
84 |
Correct |
49 ms |
12372 KB |
Output is correct |