#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;
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 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;
r[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;
r[i] = 1;
toTake = bt2[i];
dfs(i);
}
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:35:54: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
35 | if (r[y] || taken[y] || (taken & bt2[y]).count() < sz) continue;
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3928 KB |
Output is correct |
2 |
Correct |
2 ms |
3932 KB |
Output is correct |
3 |
Correct |
15 ms |
26016 KB |
Output is correct |
4 |
Correct |
12 ms |
25688 KB |
Output is correct |
5 |
Correct |
11 ms |
25436 KB |
Output is correct |
6 |
Correct |
12 ms |
25948 KB |
Output is correct |
7 |
Correct |
12 ms |
25688 KB |
Output is correct |
8 |
Correct |
14 ms |
23900 KB |
Output is correct |
9 |
Correct |
2 ms |
3928 KB |
Output is correct |
10 |
Correct |
9 ms |
24044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3928 KB |
Output is correct |
2 |
Correct |
2 ms |
3932 KB |
Output is correct |
3 |
Correct |
15 ms |
26016 KB |
Output is correct |
4 |
Correct |
12 ms |
25688 KB |
Output is correct |
5 |
Correct |
11 ms |
25436 KB |
Output is correct |
6 |
Correct |
12 ms |
25948 KB |
Output is correct |
7 |
Correct |
12 ms |
25688 KB |
Output is correct |
8 |
Correct |
14 ms |
23900 KB |
Output is correct |
9 |
Correct |
2 ms |
3928 KB |
Output is correct |
10 |
Correct |
9 ms |
24044 KB |
Output is correct |
11 |
Correct |
12 ms |
25692 KB |
Output is correct |
12 |
Correct |
13 ms |
25692 KB |
Output is correct |
13 |
Correct |
2 ms |
3932 KB |
Output is correct |
14 |
Correct |
12 ms |
25436 KB |
Output is correct |
15 |
Correct |
2 ms |
3932 KB |
Output is correct |
16 |
Correct |
12 ms |
25692 KB |
Output is correct |
17 |
Correct |
2 ms |
3932 KB |
Output is correct |
18 |
Correct |
15 ms |
25948 KB |
Output is correct |
19 |
Correct |
14 ms |
23896 KB |
Output is correct |
20 |
Correct |
12 ms |
25504 KB |
Output is correct |
21 |
Correct |
11 ms |
25436 KB |
Output is correct |
22 |
Correct |
9 ms |
23900 KB |
Output is correct |
23 |
Correct |
17 ms |
26460 KB |
Output is correct |
24 |
Correct |
9 ms |
23900 KB |
Output is correct |
25 |
Correct |
19 ms |
26380 KB |
Output is correct |
26 |
Correct |
20 ms |
26204 KB |
Output is correct |
27 |
Correct |
24 ms |
26204 KB |
Output is correct |
28 |
Correct |
18 ms |
26204 KB |
Output is correct |
29 |
Correct |
20 ms |
26204 KB |
Output is correct |
30 |
Correct |
20 ms |
26428 KB |
Output is correct |
31 |
Correct |
23 ms |
26460 KB |
Output is correct |
32 |
Correct |
20 ms |
26460 KB |
Output is correct |
33 |
Correct |
22 ms |
26456 KB |
Output is correct |
34 |
Correct |
23 ms |
26460 KB |
Output is correct |
35 |
Correct |
12 ms |
14684 KB |
Output is correct |
36 |
Correct |
11 ms |
14920 KB |
Output is correct |
37 |
Correct |
12 ms |
14928 KB |
Output is correct |
38 |
Correct |
8 ms |
9376 KB |
Output is correct |
39 |
Correct |
7 ms |
9564 KB |
Output is correct |
40 |
Correct |
22 ms |
27016 KB |
Output is correct |
41 |
Correct |
8 ms |
9308 KB |
Output is correct |
42 |
Correct |
21 ms |
26972 KB |
Output is correct |
43 |
Correct |
23 ms |
27220 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 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 |
Incorrect |
2 ms |
3932 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3928 KB |
Output is correct |
2 |
Correct |
2 ms |
3932 KB |
Output is correct |
3 |
Correct |
15 ms |
26016 KB |
Output is correct |
4 |
Correct |
12 ms |
25688 KB |
Output is correct |
5 |
Correct |
11 ms |
25436 KB |
Output is correct |
6 |
Correct |
12 ms |
25948 KB |
Output is correct |
7 |
Correct |
12 ms |
25688 KB |
Output is correct |
8 |
Correct |
14 ms |
23900 KB |
Output is correct |
9 |
Correct |
2 ms |
3928 KB |
Output is correct |
10 |
Correct |
9 ms |
24044 KB |
Output is correct |
11 |
Correct |
12 ms |
25692 KB |
Output is correct |
12 |
Correct |
13 ms |
25692 KB |
Output is correct |
13 |
Correct |
2 ms |
3932 KB |
Output is correct |
14 |
Correct |
12 ms |
25436 KB |
Output is correct |
15 |
Correct |
2 ms |
3932 KB |
Output is correct |
16 |
Correct |
12 ms |
25692 KB |
Output is correct |
17 |
Correct |
2 ms |
3932 KB |
Output is correct |
18 |
Correct |
15 ms |
25948 KB |
Output is correct |
19 |
Correct |
14 ms |
23896 KB |
Output is correct |
20 |
Correct |
12 ms |
25504 KB |
Output is correct |
21 |
Correct |
11 ms |
25436 KB |
Output is correct |
22 |
Correct |
9 ms |
23900 KB |
Output is correct |
23 |
Correct |
17 ms |
26460 KB |
Output is correct |
24 |
Correct |
9 ms |
23900 KB |
Output is correct |
25 |
Correct |
19 ms |
26380 KB |
Output is correct |
26 |
Correct |
20 ms |
26204 KB |
Output is correct |
27 |
Correct |
24 ms |
26204 KB |
Output is correct |
28 |
Correct |
18 ms |
26204 KB |
Output is correct |
29 |
Correct |
20 ms |
26204 KB |
Output is correct |
30 |
Correct |
20 ms |
26428 KB |
Output is correct |
31 |
Correct |
23 ms |
26460 KB |
Output is correct |
32 |
Correct |
20 ms |
26460 KB |
Output is correct |
33 |
Correct |
22 ms |
26456 KB |
Output is correct |
34 |
Correct |
23 ms |
26460 KB |
Output is correct |
35 |
Correct |
12 ms |
14684 KB |
Output is correct |
36 |
Correct |
11 ms |
14920 KB |
Output is correct |
37 |
Correct |
12 ms |
14928 KB |
Output is correct |
38 |
Correct |
8 ms |
9376 KB |
Output is correct |
39 |
Correct |
7 ms |
9564 KB |
Output is correct |
40 |
Correct |
22 ms |
27016 KB |
Output is correct |
41 |
Correct |
8 ms |
9308 KB |
Output is correct |
42 |
Correct |
21 ms |
26972 KB |
Output is correct |
43 |
Correct |
23 ms |
27220 KB |
Output is correct |
44 |
Correct |
18 ms |
28764 KB |
Output is correct |
45 |
Correct |
2 ms |
3932 KB |
Output is correct |
46 |
Correct |
22 ms |
27036 KB |
Output is correct |
47 |
Incorrect |
36 ms |
28572 KB |
Output isn't correct |
48 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3928 KB |
Output is correct |
2 |
Correct |
2 ms |
3932 KB |
Output is correct |
3 |
Correct |
15 ms |
26016 KB |
Output is correct |
4 |
Correct |
12 ms |
25688 KB |
Output is correct |
5 |
Correct |
11 ms |
25436 KB |
Output is correct |
6 |
Correct |
12 ms |
25948 KB |
Output is correct |
7 |
Correct |
12 ms |
25688 KB |
Output is correct |
8 |
Correct |
14 ms |
23900 KB |
Output is correct |
9 |
Correct |
2 ms |
3928 KB |
Output is correct |
10 |
Correct |
9 ms |
24044 KB |
Output is correct |
11 |
Correct |
12 ms |
25692 KB |
Output is correct |
12 |
Correct |
13 ms |
25692 KB |
Output is correct |
13 |
Correct |
2 ms |
3932 KB |
Output is correct |
14 |
Correct |
12 ms |
25436 KB |
Output is correct |
15 |
Correct |
2 ms |
3932 KB |
Output is correct |
16 |
Correct |
12 ms |
25692 KB |
Output is correct |
17 |
Correct |
2 ms |
3932 KB |
Output is correct |
18 |
Correct |
15 ms |
25948 KB |
Output is correct |
19 |
Correct |
14 ms |
23896 KB |
Output is correct |
20 |
Correct |
12 ms |
25504 KB |
Output is correct |
21 |
Correct |
11 ms |
25436 KB |
Output is correct |
22 |
Correct |
9 ms |
23900 KB |
Output is correct |
23 |
Correct |
17 ms |
26460 KB |
Output is correct |
24 |
Correct |
9 ms |
23900 KB |
Output is correct |
25 |
Correct |
19 ms |
26380 KB |
Output is correct |
26 |
Correct |
20 ms |
26204 KB |
Output is correct |
27 |
Correct |
24 ms |
26204 KB |
Output is correct |
28 |
Correct |
18 ms |
26204 KB |
Output is correct |
29 |
Correct |
20 ms |
26204 KB |
Output is correct |
30 |
Correct |
20 ms |
26428 KB |
Output is correct |
31 |
Correct |
23 ms |
26460 KB |
Output is correct |
32 |
Correct |
20 ms |
26460 KB |
Output is correct |
33 |
Correct |
22 ms |
26456 KB |
Output is correct |
34 |
Correct |
23 ms |
26460 KB |
Output is correct |
35 |
Correct |
12 ms |
14684 KB |
Output is correct |
36 |
Correct |
11 ms |
14920 KB |
Output is correct |
37 |
Correct |
12 ms |
14928 KB |
Output is correct |
38 |
Correct |
8 ms |
9376 KB |
Output is correct |
39 |
Correct |
7 ms |
9564 KB |
Output is correct |
40 |
Correct |
22 ms |
27016 KB |
Output is correct |
41 |
Correct |
8 ms |
9308 KB |
Output is correct |
42 |
Correct |
21 ms |
26972 KB |
Output is correct |
43 |
Correct |
23 ms |
27220 KB |
Output is correct |
44 |
Correct |
2 ms |
3932 KB |
Output is correct |
45 |
Incorrect |
383 ms |
326072 KB |
Output isn't correct |
46 |
Halted |
0 ms |
0 KB |
- |