#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,lzcnt,mmx,abm,avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
const int N = 5e4, X = 5e2/*, X2 = 1e3*/;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, k, c, ans;
vector<int> vt, adj[N];
set<int> st[N];
bitset<N> bt2[N], r, taken, toTake;
void clean(int x) {
for (int i = 0; i < n; i++) {
if (adj[i].size()+1 < x) r[i] = 1;
}
}
/*
void dfs2(int x) {
if (c++ > X2) return;
int sz = taken.count();
if (sz > ans) {
ans = sz;
clean(sz+1);
}
shuffle(all(adj[x]), rng);
for (int& y : adj[x]) {
if (c++ > X2) return;
if (r[y] || taken[y] || (taken & bt2[y]).count() < sz) continue;
taken[y] = 1;
bitset<N> toTakePrev = toTake;
toTake &= bt2[y];
dfs2(y);
if (c++ > X2) return;
toTake = toTakePrev;
taken[y] = 0;
}
}
*/
void dfs(int x) {
if (c++ > X) return;
int sz = taken.count();
if (sz > ans) {
ans = sz;
clean(sz+1);
}
shuffle(all(adj[x]), rng);
for (int& y : adj[x]) {
if (c++ > X) return;
if (r[y] || taken[y] || (taken & bt2[y]).count() < sz) continue;
taken[y] = 1;
bitset<N> toTakePrev = toTake;
toTake &= bt2[y];
dfs(y);
if (c++ > X) return;
toTake = toTakePrev;
taken[y] = 0;
}
}
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> k;
ans = 1;
vt.resize(n);
for (int i = 0; i < n; i++) {
vt[i] = i;
bt2[i][i] = toTake[i] = 1;
int x; cin >> x;
for (int j = 0; j < x; j++) {
int y; cin >> y;
st[i].insert(y);
if (st[y].find(i) != st[y].end()) {
bt2[i][y] = 1;
adj[i].push_back(y);
bt2[y][i] = 1;
adj[y].push_back(i);
}
}
}
for (int i = 0; i < n; i++) {
if (r[i]) continue;
c = 0;
taken.reset();
taken[i] = 1;
toTake = bt2[i];
dfs(i);
//if (n <= 5000) dfs(i);
//else dfs2(i);
if (rng() % 50 == 0) r[i] = 1;
}
cout << ans << "\n";
}
Compilation message
politicaldevelopment.cpp: In function 'void clean(int)':
politicaldevelopment.cpp:19:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
19 | if (adj[i].size()+1 < x) r[i] = 1;
| ~~~~~~~~~~~~~~~~^~~
politicaldevelopment.cpp: In function 'void dfs(int)':
politicaldevelopment.cpp:63:54: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
63 | if (r[y] || taken[y] || (taken & bt2[y]).count() < sz) continue;
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3932 KB |
Output is correct |
2 |
Correct |
2 ms |
3960 KB |
Output is correct |
3 |
Correct |
26 ms |
25948 KB |
Output is correct |
4 |
Correct |
13 ms |
25436 KB |
Output is correct |
5 |
Correct |
12 ms |
25436 KB |
Output is correct |
6 |
Correct |
14 ms |
25820 KB |
Output is correct |
7 |
Correct |
15 ms |
25692 KB |
Output is correct |
8 |
Correct |
16 ms |
23896 KB |
Output is correct |
9 |
Correct |
2 ms |
3932 KB |
Output is correct |
10 |
Correct |
10 ms |
23900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3932 KB |
Output is correct |
2 |
Correct |
2 ms |
3960 KB |
Output is correct |
3 |
Correct |
26 ms |
25948 KB |
Output is correct |
4 |
Correct |
13 ms |
25436 KB |
Output is correct |
5 |
Correct |
12 ms |
25436 KB |
Output is correct |
6 |
Correct |
14 ms |
25820 KB |
Output is correct |
7 |
Correct |
15 ms |
25692 KB |
Output is correct |
8 |
Correct |
16 ms |
23896 KB |
Output is correct |
9 |
Correct |
2 ms |
3932 KB |
Output is correct |
10 |
Correct |
10 ms |
23900 KB |
Output is correct |
11 |
Correct |
15 ms |
25944 KB |
Output is correct |
12 |
Correct |
11 ms |
25548 KB |
Output is correct |
13 |
Correct |
2 ms |
3932 KB |
Output is correct |
14 |
Correct |
14 ms |
25436 KB |
Output is correct |
15 |
Correct |
2 ms |
3932 KB |
Output is correct |
16 |
Correct |
14 ms |
25660 KB |
Output is correct |
17 |
Correct |
2 ms |
3932 KB |
Output is correct |
18 |
Correct |
15 ms |
25692 KB |
Output is correct |
19 |
Correct |
13 ms |
23984 KB |
Output is correct |
20 |
Correct |
10 ms |
25232 KB |
Output is correct |
21 |
Correct |
11 ms |
25436 KB |
Output is correct |
22 |
Correct |
8 ms |
23980 KB |
Output is correct |
23 |
Correct |
25 ms |
26200 KB |
Output is correct |
24 |
Correct |
10 ms |
23900 KB |
Output is correct |
25 |
Correct |
30 ms |
26416 KB |
Output is correct |
26 |
Correct |
40 ms |
26096 KB |
Output is correct |
27 |
Correct |
35 ms |
26204 KB |
Output is correct |
28 |
Correct |
38 ms |
25948 KB |
Output is correct |
29 |
Correct |
36 ms |
26200 KB |
Output is correct |
30 |
Correct |
425 ms |
26336 KB |
Output is correct |
31 |
Correct |
47 ms |
26460 KB |
Output is correct |
32 |
Correct |
408 ms |
26412 KB |
Output is correct |
33 |
Correct |
50 ms |
26456 KB |
Output is correct |
34 |
Correct |
54 ms |
26488 KB |
Output is correct |
35 |
Correct |
24 ms |
14684 KB |
Output is correct |
36 |
Correct |
23 ms |
14884 KB |
Output is correct |
37 |
Correct |
24 ms |
14684 KB |
Output is correct |
38 |
Correct |
51 ms |
9308 KB |
Output is correct |
39 |
Correct |
50 ms |
9308 KB |
Output is correct |
40 |
Correct |
63 ms |
27224 KB |
Output is correct |
41 |
Correct |
51 ms |
9304 KB |
Output is correct |
42 |
Correct |
68 ms |
26972 KB |
Output is correct |
43 |
Correct |
65 ms |
26972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
23900 KB |
Output is correct |
2 |
Correct |
2 ms |
3932 KB |
Output is correct |
3 |
Correct |
2 ms |
3932 KB |
Output is correct |
4 |
Correct |
2 ms |
3932 KB |
Output is correct |
5 |
Correct |
3 ms |
3932 KB |
Output is correct |
6 |
Correct |
2 ms |
3932 KB |
Output is correct |
7 |
Correct |
2 ms |
3932 KB |
Output is correct |
8 |
Correct |
2 ms |
3932 KB |
Output is correct |
9 |
Correct |
2 ms |
3988 KB |
Output is correct |
10 |
Correct |
2 ms |
4104 KB |
Output is correct |
11 |
Execution timed out |
3087 ms |
337224 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3932 KB |
Output is correct |
2 |
Correct |
2 ms |
3960 KB |
Output is correct |
3 |
Correct |
26 ms |
25948 KB |
Output is correct |
4 |
Correct |
13 ms |
25436 KB |
Output is correct |
5 |
Correct |
12 ms |
25436 KB |
Output is correct |
6 |
Correct |
14 ms |
25820 KB |
Output is correct |
7 |
Correct |
15 ms |
25692 KB |
Output is correct |
8 |
Correct |
16 ms |
23896 KB |
Output is correct |
9 |
Correct |
2 ms |
3932 KB |
Output is correct |
10 |
Correct |
10 ms |
23900 KB |
Output is correct |
11 |
Correct |
15 ms |
25944 KB |
Output is correct |
12 |
Correct |
11 ms |
25548 KB |
Output is correct |
13 |
Correct |
2 ms |
3932 KB |
Output is correct |
14 |
Correct |
14 ms |
25436 KB |
Output is correct |
15 |
Correct |
2 ms |
3932 KB |
Output is correct |
16 |
Correct |
14 ms |
25660 KB |
Output is correct |
17 |
Correct |
2 ms |
3932 KB |
Output is correct |
18 |
Correct |
15 ms |
25692 KB |
Output is correct |
19 |
Correct |
13 ms |
23984 KB |
Output is correct |
20 |
Correct |
10 ms |
25232 KB |
Output is correct |
21 |
Correct |
11 ms |
25436 KB |
Output is correct |
22 |
Correct |
8 ms |
23980 KB |
Output is correct |
23 |
Correct |
25 ms |
26200 KB |
Output is correct |
24 |
Correct |
10 ms |
23900 KB |
Output is correct |
25 |
Correct |
30 ms |
26416 KB |
Output is correct |
26 |
Correct |
40 ms |
26096 KB |
Output is correct |
27 |
Correct |
35 ms |
26204 KB |
Output is correct |
28 |
Correct |
38 ms |
25948 KB |
Output is correct |
29 |
Correct |
36 ms |
26200 KB |
Output is correct |
30 |
Correct |
425 ms |
26336 KB |
Output is correct |
31 |
Correct |
47 ms |
26460 KB |
Output is correct |
32 |
Correct |
408 ms |
26412 KB |
Output is correct |
33 |
Correct |
50 ms |
26456 KB |
Output is correct |
34 |
Correct |
54 ms |
26488 KB |
Output is correct |
35 |
Correct |
24 ms |
14684 KB |
Output is correct |
36 |
Correct |
23 ms |
14884 KB |
Output is correct |
37 |
Correct |
24 ms |
14684 KB |
Output is correct |
38 |
Correct |
51 ms |
9308 KB |
Output is correct |
39 |
Correct |
50 ms |
9308 KB |
Output is correct |
40 |
Correct |
63 ms |
27224 KB |
Output is correct |
41 |
Correct |
51 ms |
9304 KB |
Output is correct |
42 |
Correct |
68 ms |
26972 KB |
Output is correct |
43 |
Correct |
65 ms |
26972 KB |
Output is correct |
44 |
Correct |
19 ms |
28760 KB |
Output is correct |
45 |
Correct |
2 ms |
3932 KB |
Output is correct |
46 |
Correct |
54 ms |
27112 KB |
Output is correct |
47 |
Correct |
249 ms |
28508 KB |
Output is correct |
48 |
Correct |
84 ms |
26968 KB |
Output is correct |
49 |
Correct |
260 ms |
28760 KB |
Output is correct |
50 |
Correct |
270 ms |
28500 KB |
Output is correct |
51 |
Correct |
764 ms |
31316 KB |
Output is correct |
52 |
Correct |
13 ms |
25944 KB |
Output is correct |
53 |
Correct |
1755 ms |
32056 KB |
Output is correct |
54 |
Correct |
933 ms |
32068 KB |
Output is correct |
55 |
Correct |
16 ms |
25692 KB |
Output is correct |
56 |
Correct |
14 ms |
26204 KB |
Output is correct |
57 |
Correct |
15 ms |
24092 KB |
Output is correct |
58 |
Correct |
1759 ms |
31964 KB |
Output is correct |
59 |
Correct |
14 ms |
27228 KB |
Output is correct |
60 |
Correct |
15 ms |
25748 KB |
Output is correct |
61 |
Correct |
17 ms |
27740 KB |
Output is correct |
62 |
Correct |
13 ms |
27368 KB |
Output is correct |
63 |
Correct |
20 ms |
28764 KB |
Output is correct |
64 |
Correct |
18 ms |
28504 KB |
Output is correct |
65 |
Correct |
41 ms |
26920 KB |
Output is correct |
66 |
Correct |
16 ms |
27228 KB |
Output is correct |
67 |
Correct |
206 ms |
29400 KB |
Output is correct |
68 |
Correct |
16 ms |
28508 KB |
Output is correct |
69 |
Correct |
44 ms |
26856 KB |
Output is correct |
70 |
Correct |
217 ms |
28504 KB |
Output is correct |
71 |
Correct |
187 ms |
29272 KB |
Output is correct |
72 |
Correct |
251 ms |
29272 KB |
Output is correct |
73 |
Correct |
36 ms |
26204 KB |
Output is correct |
74 |
Correct |
219 ms |
28504 KB |
Output is correct |
75 |
Correct |
222 ms |
29164 KB |
Output is correct |
76 |
Correct |
706 ms |
27740 KB |
Output is correct |
77 |
Correct |
466 ms |
30200 KB |
Output is correct |
78 |
Correct |
36 ms |
26204 KB |
Output is correct |
79 |
Correct |
202 ms |
16216 KB |
Output is correct |
80 |
Correct |
701 ms |
27812 KB |
Output is correct |
81 |
Correct |
476 ms |
30104 KB |
Output is correct |
82 |
Correct |
52 ms |
9304 KB |
Output is correct |
83 |
Correct |
233 ms |
16216 KB |
Output is correct |
84 |
Correct |
289 ms |
29276 KB |
Output is correct |
85 |
Correct |
51 ms |
9308 KB |
Output is correct |
86 |
Correct |
278 ms |
29288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3932 KB |
Output is correct |
2 |
Correct |
2 ms |
3960 KB |
Output is correct |
3 |
Correct |
26 ms |
25948 KB |
Output is correct |
4 |
Correct |
13 ms |
25436 KB |
Output is correct |
5 |
Correct |
12 ms |
25436 KB |
Output is correct |
6 |
Correct |
14 ms |
25820 KB |
Output is correct |
7 |
Correct |
15 ms |
25692 KB |
Output is correct |
8 |
Correct |
16 ms |
23896 KB |
Output is correct |
9 |
Correct |
2 ms |
3932 KB |
Output is correct |
10 |
Correct |
10 ms |
23900 KB |
Output is correct |
11 |
Correct |
15 ms |
25944 KB |
Output is correct |
12 |
Correct |
11 ms |
25548 KB |
Output is correct |
13 |
Correct |
2 ms |
3932 KB |
Output is correct |
14 |
Correct |
14 ms |
25436 KB |
Output is correct |
15 |
Correct |
2 ms |
3932 KB |
Output is correct |
16 |
Correct |
14 ms |
25660 KB |
Output is correct |
17 |
Correct |
2 ms |
3932 KB |
Output is correct |
18 |
Correct |
15 ms |
25692 KB |
Output is correct |
19 |
Correct |
13 ms |
23984 KB |
Output is correct |
20 |
Correct |
10 ms |
25232 KB |
Output is correct |
21 |
Correct |
11 ms |
25436 KB |
Output is correct |
22 |
Correct |
8 ms |
23980 KB |
Output is correct |
23 |
Correct |
25 ms |
26200 KB |
Output is correct |
24 |
Correct |
10 ms |
23900 KB |
Output is correct |
25 |
Correct |
30 ms |
26416 KB |
Output is correct |
26 |
Correct |
40 ms |
26096 KB |
Output is correct |
27 |
Correct |
35 ms |
26204 KB |
Output is correct |
28 |
Correct |
38 ms |
25948 KB |
Output is correct |
29 |
Correct |
36 ms |
26200 KB |
Output is correct |
30 |
Correct |
425 ms |
26336 KB |
Output is correct |
31 |
Correct |
47 ms |
26460 KB |
Output is correct |
32 |
Correct |
408 ms |
26412 KB |
Output is correct |
33 |
Correct |
50 ms |
26456 KB |
Output is correct |
34 |
Correct |
54 ms |
26488 KB |
Output is correct |
35 |
Correct |
24 ms |
14684 KB |
Output is correct |
36 |
Correct |
23 ms |
14884 KB |
Output is correct |
37 |
Correct |
24 ms |
14684 KB |
Output is correct |
38 |
Correct |
51 ms |
9308 KB |
Output is correct |
39 |
Correct |
50 ms |
9308 KB |
Output is correct |
40 |
Correct |
63 ms |
27224 KB |
Output is correct |
41 |
Correct |
51 ms |
9304 KB |
Output is correct |
42 |
Correct |
68 ms |
26972 KB |
Output is correct |
43 |
Correct |
65 ms |
26972 KB |
Output is correct |
44 |
Correct |
2 ms |
3928 KB |
Output is correct |
45 |
Correct |
2367 ms |
326668 KB |
Output is correct |
46 |
Correct |
332 ms |
308304 KB |
Output is correct |
47 |
Correct |
1912 ms |
326480 KB |
Output is correct |
48 |
Correct |
2111 ms |
326484 KB |
Output is correct |
49 |
Correct |
135 ms |
280808 KB |
Output is correct |
50 |
Execution timed out |
3084 ms |
333512 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |