#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,sse,sse2")
#include <bits/stdc++.h>
using namespace std;
const int mxN = 50000;
using S = bitset<mxN>;
S g[mxN];
int ans = 0;
void find_max(S can, int has) {
ans = max(has, ans);
while (can.any()) {
int cur = (int)can._Find_first();
can.reset(cur);
S nxt_s = can & g[cur];
if ((int)nxt_s.count()+has+1 > ans) {
find_max(nxt_s, has+1);
}
}
}
int main() {
ios::sync_with_stdio(0);cin.tie(0);
int n, k; cin >> n >> k;
for (int i = 0; i < n; ++i) {
int s; cin >> s;
g[i].set(i);
for (int ss = 0; ss < s; ++ss) {
int j; cin >> j;
g[i].set(j);
}
}
/*
for (int i = 0; i < n; ++i)
cerr << g[i] << '\n'; // */
S init;
for (int i = 0; i < n; ++i) init.set(i);
find_max(init, 0);
cout << ans << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
27 ms |
21836 KB |
Output is correct |
4 |
Correct |
27 ms |
21312 KB |
Output is correct |
5 |
Correct |
26 ms |
21232 KB |
Output is correct |
6 |
Correct |
27 ms |
21604 KB |
Output is correct |
7 |
Correct |
26 ms |
21604 KB |
Output is correct |
8 |
Correct |
20 ms |
20412 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
20 ms |
20428 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
27 ms |
21836 KB |
Output is correct |
4 |
Correct |
27 ms |
21312 KB |
Output is correct |
5 |
Correct |
26 ms |
21232 KB |
Output is correct |
6 |
Correct |
27 ms |
21604 KB |
Output is correct |
7 |
Correct |
26 ms |
21604 KB |
Output is correct |
8 |
Correct |
20 ms |
20412 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
20 ms |
20428 KB |
Output is correct |
11 |
Correct |
27 ms |
21320 KB |
Output is correct |
12 |
Correct |
27 ms |
21324 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
25 ms |
21256 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
26 ms |
21456 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
25 ms |
21648 KB |
Output is correct |
19 |
Correct |
20 ms |
20300 KB |
Output is correct |
20 |
Correct |
21 ms |
21432 KB |
Output is correct |
21 |
Correct |
21 ms |
21452 KB |
Output is correct |
22 |
Correct |
21 ms |
20308 KB |
Output is correct |
23 |
Correct |
27 ms |
22024 KB |
Output is correct |
24 |
Correct |
20 ms |
20428 KB |
Output is correct |
25 |
Correct |
29 ms |
22096 KB |
Output is correct |
26 |
Correct |
30 ms |
21968 KB |
Output is correct |
27 |
Correct |
29 ms |
22000 KB |
Output is correct |
28 |
Correct |
30 ms |
22028 KB |
Output is correct |
29 |
Correct |
28 ms |
22048 KB |
Output is correct |
30 |
Correct |
31 ms |
21912 KB |
Output is correct |
31 |
Correct |
32 ms |
22248 KB |
Output is correct |
32 |
Correct |
31 ms |
21892 KB |
Output is correct |
33 |
Correct |
39 ms |
22096 KB |
Output is correct |
34 |
Correct |
33 ms |
22172 KB |
Output is correct |
35 |
Correct |
16 ms |
10828 KB |
Output is correct |
36 |
Correct |
16 ms |
10736 KB |
Output is correct |
37 |
Correct |
16 ms |
10828 KB |
Output is correct |
38 |
Correct |
9 ms |
5464 KB |
Output is correct |
39 |
Correct |
9 ms |
5324 KB |
Output is correct |
40 |
Correct |
35 ms |
22296 KB |
Output is correct |
41 |
Correct |
9 ms |
5324 KB |
Output is correct |
42 |
Correct |
37 ms |
22348 KB |
Output is correct |
43 |
Correct |
35 ms |
22396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
20300 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
920 ms |
309016 KB |
Output is correct |
12 |
Correct |
1 ms |
460 KB |
Output is correct |
13 |
Correct |
421 ms |
309108 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
925 ms |
309036 KB |
Output is correct |
16 |
Correct |
575 ms |
309100 KB |
Output is correct |
17 |
Correct |
457 ms |
309044 KB |
Output is correct |
18 |
Correct |
552 ms |
309092 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
27 ms |
21836 KB |
Output is correct |
4 |
Correct |
27 ms |
21312 KB |
Output is correct |
5 |
Correct |
26 ms |
21232 KB |
Output is correct |
6 |
Correct |
27 ms |
21604 KB |
Output is correct |
7 |
Correct |
26 ms |
21604 KB |
Output is correct |
8 |
Correct |
20 ms |
20412 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
20 ms |
20428 KB |
Output is correct |
11 |
Correct |
27 ms |
21320 KB |
Output is correct |
12 |
Correct |
27 ms |
21324 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
25 ms |
21256 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
26 ms |
21456 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
25 ms |
21648 KB |
Output is correct |
19 |
Correct |
20 ms |
20300 KB |
Output is correct |
20 |
Correct |
21 ms |
21432 KB |
Output is correct |
21 |
Correct |
21 ms |
21452 KB |
Output is correct |
22 |
Correct |
21 ms |
20308 KB |
Output is correct |
23 |
Correct |
27 ms |
22024 KB |
Output is correct |
24 |
Correct |
20 ms |
20428 KB |
Output is correct |
25 |
Correct |
29 ms |
22096 KB |
Output is correct |
26 |
Correct |
30 ms |
21968 KB |
Output is correct |
27 |
Correct |
29 ms |
22000 KB |
Output is correct |
28 |
Correct |
30 ms |
22028 KB |
Output is correct |
29 |
Correct |
28 ms |
22048 KB |
Output is correct |
30 |
Correct |
31 ms |
21912 KB |
Output is correct |
31 |
Correct |
32 ms |
22248 KB |
Output is correct |
32 |
Correct |
31 ms |
21892 KB |
Output is correct |
33 |
Correct |
39 ms |
22096 KB |
Output is correct |
34 |
Correct |
33 ms |
22172 KB |
Output is correct |
35 |
Correct |
16 ms |
10828 KB |
Output is correct |
36 |
Correct |
16 ms |
10736 KB |
Output is correct |
37 |
Correct |
16 ms |
10828 KB |
Output is correct |
38 |
Correct |
9 ms |
5464 KB |
Output is correct |
39 |
Correct |
9 ms |
5324 KB |
Output is correct |
40 |
Correct |
35 ms |
22296 KB |
Output is correct |
41 |
Correct |
9 ms |
5324 KB |
Output is correct |
42 |
Correct |
37 ms |
22348 KB |
Output is correct |
43 |
Correct |
35 ms |
22396 KB |
Output is correct |
44 |
Correct |
25 ms |
23084 KB |
Output is correct |
45 |
Correct |
1 ms |
332 KB |
Output is correct |
46 |
Correct |
40 ms |
22284 KB |
Output is correct |
47 |
Correct |
50 ms |
22812 KB |
Output is correct |
48 |
Correct |
35 ms |
22320 KB |
Output is correct |
49 |
Correct |
49 ms |
22956 KB |
Output is correct |
50 |
Correct |
52 ms |
22888 KB |
Output is correct |
51 |
Correct |
78 ms |
23456 KB |
Output is correct |
52 |
Correct |
29 ms |
21712 KB |
Output is correct |
53 |
Correct |
100 ms |
23488 KB |
Output is correct |
54 |
Correct |
89 ms |
23500 KB |
Output is correct |
55 |
Correct |
28 ms |
21464 KB |
Output is correct |
56 |
Correct |
30 ms |
21836 KB |
Output is correct |
57 |
Correct |
24 ms |
20412 KB |
Output is correct |
58 |
Correct |
101 ms |
23372 KB |
Output is correct |
59 |
Correct |
23 ms |
22476 KB |
Output is correct |
60 |
Correct |
26 ms |
21584 KB |
Output is correct |
61 |
Correct |
22 ms |
22604 KB |
Output is correct |
62 |
Correct |
23 ms |
22732 KB |
Output is correct |
63 |
Correct |
25 ms |
23184 KB |
Output is correct |
64 |
Correct |
24 ms |
23068 KB |
Output is correct |
65 |
Correct |
30 ms |
22348 KB |
Output is correct |
66 |
Correct |
26 ms |
22564 KB |
Output is correct |
67 |
Correct |
43 ms |
23120 KB |
Output is correct |
68 |
Correct |
24 ms |
22972 KB |
Output is correct |
69 |
Correct |
31 ms |
22312 KB |
Output is correct |
70 |
Correct |
39 ms |
22920 KB |
Output is correct |
71 |
Correct |
41 ms |
23092 KB |
Output is correct |
72 |
Correct |
43 ms |
23092 KB |
Output is correct |
73 |
Correct |
29 ms |
21836 KB |
Output is correct |
74 |
Correct |
43 ms |
22996 KB |
Output is correct |
75 |
Correct |
44 ms |
23248 KB |
Output is correct |
76 |
Correct |
43 ms |
22692 KB |
Output is correct |
77 |
Correct |
76 ms |
23288 KB |
Output is correct |
78 |
Correct |
29 ms |
21948 KB |
Output is correct |
79 |
Correct |
37 ms |
11140 KB |
Output is correct |
80 |
Correct |
43 ms |
22604 KB |
Output is correct |
81 |
Correct |
78 ms |
23244 KB |
Output is correct |
82 |
Correct |
11 ms |
5460 KB |
Output is correct |
83 |
Correct |
39 ms |
11084 KB |
Output is correct |
84 |
Correct |
47 ms |
23216 KB |
Output is correct |
85 |
Correct |
9 ms |
5452 KB |
Output is correct |
86 |
Correct |
40 ms |
23116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
27 ms |
21836 KB |
Output is correct |
4 |
Correct |
27 ms |
21312 KB |
Output is correct |
5 |
Correct |
26 ms |
21232 KB |
Output is correct |
6 |
Correct |
27 ms |
21604 KB |
Output is correct |
7 |
Correct |
26 ms |
21604 KB |
Output is correct |
8 |
Correct |
20 ms |
20412 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
20 ms |
20428 KB |
Output is correct |
11 |
Correct |
27 ms |
21320 KB |
Output is correct |
12 |
Correct |
27 ms |
21324 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
25 ms |
21256 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
26 ms |
21456 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
25 ms |
21648 KB |
Output is correct |
19 |
Correct |
20 ms |
20300 KB |
Output is correct |
20 |
Correct |
21 ms |
21432 KB |
Output is correct |
21 |
Correct |
21 ms |
21452 KB |
Output is correct |
22 |
Correct |
21 ms |
20308 KB |
Output is correct |
23 |
Correct |
27 ms |
22024 KB |
Output is correct |
24 |
Correct |
20 ms |
20428 KB |
Output is correct |
25 |
Correct |
29 ms |
22096 KB |
Output is correct |
26 |
Correct |
30 ms |
21968 KB |
Output is correct |
27 |
Correct |
29 ms |
22000 KB |
Output is correct |
28 |
Correct |
30 ms |
22028 KB |
Output is correct |
29 |
Correct |
28 ms |
22048 KB |
Output is correct |
30 |
Correct |
31 ms |
21912 KB |
Output is correct |
31 |
Correct |
32 ms |
22248 KB |
Output is correct |
32 |
Correct |
31 ms |
21892 KB |
Output is correct |
33 |
Correct |
39 ms |
22096 KB |
Output is correct |
34 |
Correct |
33 ms |
22172 KB |
Output is correct |
35 |
Correct |
16 ms |
10828 KB |
Output is correct |
36 |
Correct |
16 ms |
10736 KB |
Output is correct |
37 |
Correct |
16 ms |
10828 KB |
Output is correct |
38 |
Correct |
9 ms |
5464 KB |
Output is correct |
39 |
Correct |
9 ms |
5324 KB |
Output is correct |
40 |
Correct |
35 ms |
22296 KB |
Output is correct |
41 |
Correct |
9 ms |
5324 KB |
Output is correct |
42 |
Correct |
37 ms |
22348 KB |
Output is correct |
43 |
Correct |
35 ms |
22396 KB |
Output is correct |
44 |
Correct |
1 ms |
332 KB |
Output is correct |
45 |
Correct |
573 ms |
306336 KB |
Output is correct |
46 |
Correct |
356 ms |
296668 KB |
Output is correct |
47 |
Correct |
523 ms |
305788 KB |
Output is correct |
48 |
Correct |
550 ms |
306368 KB |
Output is correct |
49 |
Correct |
283 ms |
270644 KB |
Output is correct |
50 |
Correct |
668 ms |
308728 KB |
Output is correct |
51 |
Correct |
569 ms |
305836 KB |
Output is correct |
52 |
Correct |
300 ms |
265672 KB |
Output is correct |
53 |
Correct |
287 ms |
270644 KB |
Output is correct |
54 |
Correct |
217 ms |
201028 KB |
Output is correct |
55 |
Correct |
727 ms |
308872 KB |
Output is correct |
56 |
Correct |
242 ms |
265540 KB |
Output is correct |
57 |
Correct |
305 ms |
266936 KB |
Output is correct |
58 |
Correct |
250 ms |
301124 KB |
Output is correct |
59 |
Correct |
227 ms |
265540 KB |
Output is correct |
60 |
Correct |
228 ms |
265492 KB |
Output is correct |
61 |
Correct |
252 ms |
300868 KB |
Output is correct |
62 |
Correct |
240 ms |
290884 KB |
Output is correct |
63 |
Correct |
354 ms |
298632 KB |
Output is correct |
64 |
Correct |
229 ms |
265080 KB |
Output is correct |
65 |
Correct |
377 ms |
302628 KB |
Output is correct |
66 |
Correct |
243 ms |
291288 KB |
Output is correct |
67 |
Correct |
388 ms |
298284 KB |
Output is correct |
68 |
Correct |
475 ms |
301804 KB |
Output is correct |
69 |
Correct |
380 ms |
302108 KB |
Output is correct |
70 |
Correct |
344 ms |
290884 KB |
Output is correct |
71 |
Correct |
411 ms |
302064 KB |
Output is correct |
72 |
Correct |
389 ms |
295364 KB |
Output is correct |
73 |
Correct |
619 ms |
306564 KB |
Output is correct |
74 |
Correct |
340 ms |
291012 KB |
Output is correct |
75 |
Correct |
229 ms |
146164 KB |
Output is correct |
76 |
Correct |
430 ms |
292548 KB |
Output is correct |
77 |
Correct |
620 ms |
306596 KB |
Output is correct |
78 |
Correct |
270 ms |
149188 KB |
Output is correct |
79 |
Correct |
229 ms |
146160 KB |
Output is correct |
80 |
Correct |
98 ms |
60100 KB |
Output is correct |
81 |
Correct |
275 ms |
149276 KB |
Output is correct |
82 |
Correct |
457 ms |
305148 KB |
Output is correct |
83 |
Correct |
99 ms |
60276 KB |
Output is correct |
84 |
Correct |
459 ms |
304860 KB |
Output is correct |