#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 = 1e3;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, k, c, ans;
vector<int> vt, adj[N];
bitset<N> bt[N], bt2[N], taken, toTake;
void dfs2(int x) {
if (c++ > X) return;
int sz = taken.count();
ans = max(ans, sz);
shuffle(all(adj[x]), rng);
for (int& y : adj[x]) {
if (c++ > X) return;
if (!taken[y] && (taken & bt2[y]).count() < sz) continue;
taken[y] = 1;
bitset<N> toTakePrev = toTake;
toTake &= bt2[y];
dfs2(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;
bt[i][y] = 1;
if (bt[y][i]) {
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++) {
c = 0;
taken.reset();
taken[i] = 1;
toTake = bt2[i];
dfs2(i);
}
cout << ans << "\n";
}
Compilation message
politicaldevelopment.cpp: In function 'void dfs2(int)':
politicaldevelopment.cpp:25:47: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
25 | if (!taken[y] && (taken & bt2[y]).count() < sz) continue;
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
4444 KB |
Output is correct |
2 |
Correct |
6 ms |
4464 KB |
Output is correct |
3 |
Correct |
1491 ms |
46888 KB |
Output is correct |
4 |
Correct |
2924 ms |
42892 KB |
Output is correct |
5 |
Correct |
2923 ms |
42812 KB |
Output is correct |
6 |
Correct |
2221 ms |
43684 KB |
Output is correct |
7 |
Correct |
2220 ms |
43528 KB |
Output is correct |
8 |
Correct |
12 ms |
21592 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
15 ms |
24668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
4444 KB |
Output is correct |
2 |
Correct |
6 ms |
4464 KB |
Output is correct |
3 |
Correct |
1491 ms |
46888 KB |
Output is correct |
4 |
Correct |
2924 ms |
42892 KB |
Output is correct |
5 |
Correct |
2923 ms |
42812 KB |
Output is correct |
6 |
Correct |
2221 ms |
43684 KB |
Output is correct |
7 |
Correct |
2220 ms |
43528 KB |
Output is correct |
8 |
Correct |
12 ms |
21592 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
15 ms |
24668 KB |
Output is correct |
11 |
Execution timed out |
3067 ms |
42948 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
21596 KB |
Output is correct |
2 |
Correct |
9 ms |
4012 KB |
Output is correct |
3 |
Correct |
9 ms |
4184 KB |
Output is correct |
4 |
Correct |
7 ms |
4356 KB |
Output is correct |
5 |
Correct |
9 ms |
4440 KB |
Output is correct |
6 |
Correct |
9 ms |
4688 KB |
Output is correct |
7 |
Correct |
11 ms |
4444 KB |
Output is correct |
8 |
Correct |
9 ms |
4444 KB |
Output is correct |
9 |
Correct |
9 ms |
4444 KB |
Output is correct |
10 |
Correct |
9 ms |
4400 KB |
Output is correct |
11 |
Runtime error |
267 ms |
524288 KB |
Execution killed with signal 9 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
4444 KB |
Output is correct |
2 |
Correct |
6 ms |
4464 KB |
Output is correct |
3 |
Correct |
1491 ms |
46888 KB |
Output is correct |
4 |
Correct |
2924 ms |
42892 KB |
Output is correct |
5 |
Correct |
2923 ms |
42812 KB |
Output is correct |
6 |
Correct |
2221 ms |
43684 KB |
Output is correct |
7 |
Correct |
2220 ms |
43528 KB |
Output is correct |
8 |
Correct |
12 ms |
21592 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
15 ms |
24668 KB |
Output is correct |
11 |
Execution timed out |
3067 ms |
42948 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
4444 KB |
Output is correct |
2 |
Correct |
6 ms |
4464 KB |
Output is correct |
3 |
Correct |
1491 ms |
46888 KB |
Output is correct |
4 |
Correct |
2924 ms |
42892 KB |
Output is correct |
5 |
Correct |
2923 ms |
42812 KB |
Output is correct |
6 |
Correct |
2221 ms |
43684 KB |
Output is correct |
7 |
Correct |
2220 ms |
43528 KB |
Output is correct |
8 |
Correct |
12 ms |
21592 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
15 ms |
24668 KB |
Output is correct |
11 |
Execution timed out |
3067 ms |
42948 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |