#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
int n, k, s = 1;
cin >> n >> k;
vector< set<int> > g(n);
vector<int> q;
for(int i = 0, j, a; i < n; i++){
cin >> j;
if(j < k) q.push_back(i);
while(j--){
cin >> a;
g[i].insert(a);
}
}
while(!q.empty()){
int u = q.back();
q.pop_back();
vector<int> p, c(g[u].size());
for(int i : g[u]) p.push_back(i);
for(int i = 0; i < (int)g[u].size(); i++)
for(int j = 0; j < (int)g[u].size(); j++)
if(g[p[i]].count(p[j]) || i == j) c[i] |= (1<<j);
for(int i = 1, p; i < 1<<(int)g[u].size(); i++){
p = 1;
for(int j = 0; j < (int)g[u].size(); j++)
if(i&(1<<j) && i != (i&c[j])) p = 0;
if(p) s = max(s, __builtin_popcount(i)+1);
}
for(int j : g[u]){
g[j].erase(u);
if((int)g[j].size() == k-1) q.push_back(j);
}
}
cout << s << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
1152 KB |
Output is correct |
4 |
Correct |
4 ms |
1152 KB |
Output is correct |
5 |
Correct |
5 ms |
1152 KB |
Output is correct |
6 |
Correct |
4 ms |
1152 KB |
Output is correct |
7 |
Correct |
4 ms |
1152 KB |
Output is correct |
8 |
Correct |
1 ms |
640 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
1152 KB |
Output is correct |
4 |
Correct |
4 ms |
1152 KB |
Output is correct |
5 |
Correct |
5 ms |
1152 KB |
Output is correct |
6 |
Correct |
4 ms |
1152 KB |
Output is correct |
7 |
Correct |
4 ms |
1152 KB |
Output is correct |
8 |
Correct |
1 ms |
640 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
640 KB |
Output is correct |
11 |
Correct |
6 ms |
1280 KB |
Output is correct |
12 |
Correct |
5 ms |
1152 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
1152 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
4 ms |
1152 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
1152 KB |
Output is correct |
19 |
Correct |
2 ms |
640 KB |
Output is correct |
20 |
Correct |
2 ms |
896 KB |
Output is correct |
21 |
Correct |
3 ms |
896 KB |
Output is correct |
22 |
Correct |
1 ms |
640 KB |
Output is correct |
23 |
Correct |
6 ms |
1280 KB |
Output is correct |
24 |
Correct |
1 ms |
640 KB |
Output is correct |
25 |
Correct |
5 ms |
1280 KB |
Output is correct |
26 |
Correct |
5 ms |
1152 KB |
Output is correct |
27 |
Correct |
5 ms |
1152 KB |
Output is correct |
28 |
Correct |
5 ms |
1152 KB |
Output is correct |
29 |
Correct |
4 ms |
1152 KB |
Output is correct |
30 |
Correct |
6 ms |
1280 KB |
Output is correct |
31 |
Correct |
5 ms |
1280 KB |
Output is correct |
32 |
Correct |
7 ms |
1280 KB |
Output is correct |
33 |
Correct |
5 ms |
1280 KB |
Output is correct |
34 |
Correct |
5 ms |
1280 KB |
Output is correct |
35 |
Correct |
3 ms |
768 KB |
Output is correct |
36 |
Correct |
3 ms |
768 KB |
Output is correct |
37 |
Correct |
3 ms |
768 KB |
Output is correct |
38 |
Correct |
2 ms |
640 KB |
Output is correct |
39 |
Correct |
2 ms |
640 KB |
Output is correct |
40 |
Correct |
8 ms |
1664 KB |
Output is correct |
41 |
Correct |
2 ms |
640 KB |
Output is correct |
42 |
Correct |
8 ms |
1664 KB |
Output is correct |
43 |
Correct |
8 ms |
1664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
640 KB |
Output is correct |
2 |
Correct |
1 ms |
288 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
367 ms |
26612 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
369 ms |
26672 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
376 ms |
26612 KB |
Output is correct |
16 |
Correct |
383 ms |
26636 KB |
Output is correct |
17 |
Correct |
375 ms |
26612 KB |
Output is correct |
18 |
Correct |
379 ms |
26612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
1152 KB |
Output is correct |
4 |
Correct |
4 ms |
1152 KB |
Output is correct |
5 |
Correct |
5 ms |
1152 KB |
Output is correct |
6 |
Correct |
4 ms |
1152 KB |
Output is correct |
7 |
Correct |
4 ms |
1152 KB |
Output is correct |
8 |
Correct |
1 ms |
640 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
640 KB |
Output is correct |
11 |
Correct |
6 ms |
1280 KB |
Output is correct |
12 |
Correct |
5 ms |
1152 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
1152 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
4 ms |
1152 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
1152 KB |
Output is correct |
19 |
Correct |
2 ms |
640 KB |
Output is correct |
20 |
Correct |
2 ms |
896 KB |
Output is correct |
21 |
Correct |
3 ms |
896 KB |
Output is correct |
22 |
Correct |
1 ms |
640 KB |
Output is correct |
23 |
Correct |
6 ms |
1280 KB |
Output is correct |
24 |
Correct |
1 ms |
640 KB |
Output is correct |
25 |
Correct |
5 ms |
1280 KB |
Output is correct |
26 |
Correct |
5 ms |
1152 KB |
Output is correct |
27 |
Correct |
5 ms |
1152 KB |
Output is correct |
28 |
Correct |
5 ms |
1152 KB |
Output is correct |
29 |
Correct |
4 ms |
1152 KB |
Output is correct |
30 |
Correct |
6 ms |
1280 KB |
Output is correct |
31 |
Correct |
5 ms |
1280 KB |
Output is correct |
32 |
Correct |
7 ms |
1280 KB |
Output is correct |
33 |
Correct |
5 ms |
1280 KB |
Output is correct |
34 |
Correct |
5 ms |
1280 KB |
Output is correct |
35 |
Correct |
3 ms |
768 KB |
Output is correct |
36 |
Correct |
3 ms |
768 KB |
Output is correct |
37 |
Correct |
3 ms |
768 KB |
Output is correct |
38 |
Correct |
2 ms |
640 KB |
Output is correct |
39 |
Correct |
2 ms |
640 KB |
Output is correct |
40 |
Correct |
8 ms |
1664 KB |
Output is correct |
41 |
Correct |
2 ms |
640 KB |
Output is correct |
42 |
Correct |
8 ms |
1664 KB |
Output is correct |
43 |
Correct |
8 ms |
1664 KB |
Output is correct |
44 |
Correct |
21 ms |
2688 KB |
Output is correct |
45 |
Correct |
1 ms |
384 KB |
Output is correct |
46 |
Correct |
10 ms |
1664 KB |
Output is correct |
47 |
Correct |
20 ms |
2688 KB |
Output is correct |
48 |
Correct |
8 ms |
1664 KB |
Output is correct |
49 |
Correct |
18 ms |
2688 KB |
Output is correct |
50 |
Correct |
21 ms |
2688 KB |
Output is correct |
51 |
Correct |
70 ms |
4736 KB |
Output is correct |
52 |
Correct |
4 ms |
1168 KB |
Output is correct |
53 |
Correct |
105 ms |
5248 KB |
Output is correct |
54 |
Correct |
109 ms |
5248 KB |
Output is correct |
55 |
Correct |
5 ms |
1152 KB |
Output is correct |
56 |
Correct |
4 ms |
1152 KB |
Output is correct |
57 |
Correct |
1 ms |
640 KB |
Output is correct |
58 |
Correct |
107 ms |
5248 KB |
Output is correct |
59 |
Correct |
7 ms |
1664 KB |
Output is correct |
60 |
Correct |
5 ms |
1152 KB |
Output is correct |
61 |
Correct |
7 ms |
1664 KB |
Output is correct |
62 |
Correct |
7 ms |
1664 KB |
Output is correct |
63 |
Correct |
21 ms |
2688 KB |
Output is correct |
64 |
Correct |
16 ms |
2432 KB |
Output is correct |
65 |
Correct |
7 ms |
1664 KB |
Output is correct |
66 |
Correct |
7 ms |
1664 KB |
Output is correct |
67 |
Correct |
55 ms |
3072 KB |
Output is correct |
68 |
Correct |
15 ms |
2432 KB |
Output is correct |
69 |
Correct |
7 ms |
1536 KB |
Output is correct |
70 |
Correct |
19 ms |
2432 KB |
Output is correct |
71 |
Correct |
53 ms |
3072 KB |
Output is correct |
72 |
Correct |
48 ms |
2944 KB |
Output is correct |
73 |
Correct |
4 ms |
1152 KB |
Output is correct |
74 |
Correct |
21 ms |
2560 KB |
Output is correct |
75 |
Correct |
50 ms |
2944 KB |
Output is correct |
76 |
Correct |
13 ms |
2048 KB |
Output is correct |
77 |
Correct |
59 ms |
3640 KB |
Output is correct |
78 |
Correct |
4 ms |
1152 KB |
Output is correct |
79 |
Correct |
29 ms |
1920 KB |
Output is correct |
80 |
Correct |
12 ms |
1920 KB |
Output is correct |
81 |
Correct |
60 ms |
3584 KB |
Output is correct |
82 |
Correct |
3 ms |
640 KB |
Output is correct |
83 |
Correct |
33 ms |
1920 KB |
Output is correct |
84 |
Correct |
31 ms |
2944 KB |
Output is correct |
85 |
Correct |
2 ms |
640 KB |
Output is correct |
86 |
Correct |
30 ms |
2944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
1152 KB |
Output is correct |
4 |
Correct |
4 ms |
1152 KB |
Output is correct |
5 |
Correct |
5 ms |
1152 KB |
Output is correct |
6 |
Correct |
4 ms |
1152 KB |
Output is correct |
7 |
Correct |
4 ms |
1152 KB |
Output is correct |
8 |
Correct |
1 ms |
640 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
640 KB |
Output is correct |
11 |
Correct |
6 ms |
1280 KB |
Output is correct |
12 |
Correct |
5 ms |
1152 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
1152 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
4 ms |
1152 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
1152 KB |
Output is correct |
19 |
Correct |
2 ms |
640 KB |
Output is correct |
20 |
Correct |
2 ms |
896 KB |
Output is correct |
21 |
Correct |
3 ms |
896 KB |
Output is correct |
22 |
Correct |
1 ms |
640 KB |
Output is correct |
23 |
Correct |
6 ms |
1280 KB |
Output is correct |
24 |
Correct |
1 ms |
640 KB |
Output is correct |
25 |
Correct |
5 ms |
1280 KB |
Output is correct |
26 |
Correct |
5 ms |
1152 KB |
Output is correct |
27 |
Correct |
5 ms |
1152 KB |
Output is correct |
28 |
Correct |
5 ms |
1152 KB |
Output is correct |
29 |
Correct |
4 ms |
1152 KB |
Output is correct |
30 |
Correct |
6 ms |
1280 KB |
Output is correct |
31 |
Correct |
5 ms |
1280 KB |
Output is correct |
32 |
Correct |
7 ms |
1280 KB |
Output is correct |
33 |
Correct |
5 ms |
1280 KB |
Output is correct |
34 |
Correct |
5 ms |
1280 KB |
Output is correct |
35 |
Correct |
3 ms |
768 KB |
Output is correct |
36 |
Correct |
3 ms |
768 KB |
Output is correct |
37 |
Correct |
3 ms |
768 KB |
Output is correct |
38 |
Correct |
2 ms |
640 KB |
Output is correct |
39 |
Correct |
2 ms |
640 KB |
Output is correct |
40 |
Correct |
8 ms |
1664 KB |
Output is correct |
41 |
Correct |
2 ms |
640 KB |
Output is correct |
42 |
Correct |
8 ms |
1664 KB |
Output is correct |
43 |
Correct |
8 ms |
1664 KB |
Output is correct |
44 |
Correct |
1 ms |
384 KB |
Output is correct |
45 |
Correct |
201 ms |
18784 KB |
Output is correct |
46 |
Correct |
92 ms |
10868 KB |
Output is correct |
47 |
Correct |
172 ms |
18680 KB |
Output is correct |
48 |
Correct |
195 ms |
18680 KB |
Output is correct |
49 |
Correct |
49 ms |
8308 KB |
Output is correct |
50 |
Correct |
232 ms |
24052 KB |
Output is correct |
51 |
Correct |
179 ms |
18680 KB |
Output is correct |
52 |
Correct |
49 ms |
8316 KB |
Output is correct |
53 |
Correct |
65 ms |
8308 KB |
Output is correct |
54 |
Correct |
9 ms |
3200 KB |
Output is correct |
55 |
Correct |
245 ms |
24180 KB |
Output is correct |
56 |
Correct |
23 ms |
5628 KB |
Output is correct |
57 |
Correct |
43 ms |
8316 KB |
Output is correct |
58 |
Correct |
76 ms |
10868 KB |
Output is correct |
59 |
Correct |
23 ms |
5628 KB |
Output is correct |
60 |
Correct |
22 ms |
5652 KB |
Output is correct |
61 |
Correct |
63 ms |
10868 KB |
Output is correct |
62 |
Correct |
40 ms |
8316 KB |
Output is correct |
63 |
Correct |
84 ms |
12160 KB |
Output is correct |
64 |
Correct |
22 ms |
5628 KB |
Output is correct |
65 |
Correct |
123 ms |
14848 KB |
Output is correct |
66 |
Correct |
39 ms |
8308 KB |
Output is correct |
67 |
Correct |
88 ms |
12152 KB |
Output is correct |
68 |
Correct |
112 ms |
14200 KB |
Output is correct |
69 |
Correct |
121 ms |
15096 KB |
Output is correct |
70 |
Correct |
39 ms |
8316 KB |
Output is correct |
71 |
Correct |
112 ms |
14076 KB |
Output is correct |
72 |
Correct |
92 ms |
11764 KB |
Output is correct |
73 |
Correct |
140 ms |
16364 KB |
Output is correct |
74 |
Correct |
42 ms |
8340 KB |
Output is correct |
75 |
Correct |
44 ms |
6784 KB |
Output is correct |
76 |
Correct |
92 ms |
11800 KB |
Output is correct |
77 |
Correct |
137 ms |
16376 KB |
Output is correct |
78 |
Correct |
69 ms |
8312 KB |
Output is correct |
79 |
Correct |
45 ms |
6656 KB |
Output is correct |
80 |
Correct |
20 ms |
3584 KB |
Output is correct |
81 |
Correct |
72 ms |
8320 KB |
Output is correct |
82 |
Correct |
90 ms |
13560 KB |
Output is correct |
83 |
Correct |
22 ms |
3584 KB |
Output is correct |
84 |
Correct |
88 ms |
13560 KB |
Output is correct |