#include <bits/stdc++.h>
using namespace std;
#ifdef MIKU
const string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif
#define int long long
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
typedef pair<int, int> pii;
const int MXN = 50005;
int n, k, ans = 1;
vector<int> edge[MXN];
int in[MXN];
bitset<MXN> ban;
set<pii> S;
unordered_set<int> EA;
bitset<1 << 10> dp;
int POPCNT(int I) {
return bitset<16>(I).count();
}
int calc(int id) {
debug(id);
ban[id] = true;
vector<int> v;
for (auto &i : edge[id]) {
if (ban[i]) continue;
S.erase(S.find(mp(in[i], i)));
S.insert(mp(--in[i], i));
v.push_back(i);
}
int n = v.size();
// for (auto &i : v) cout << i << ' ';
// cout << endl;
dp.reset();
dp[0] = true;
FOR(i, 0, n) {
int I = 0;
FOR(j, 0, i) if (EA.find(v[j] * MXN + v[i]) != EA.end()) I ^= (1 << j);
for (int j = I; true; j = ((j - 1) & I)) {
dp[j ^ (1 << i)] = dp[j];
if (j == 0) break;
}
}
int ans = 0;
FOR(I, 0, 1 << n) if (dp[I]) ans = max(ans, POPCNT(I));
return ans + 1;
}
void miku() {
int c, x;
cin >> n >> k;
FOR(i, 0, n) {
cin >> c;
while (c--) {
cin >> x;
edge[i].push_back(x);
EA.insert(i * MXN + x);
}
}
FOR(i, 0, n) S.insert(mp(in[i] = edge[i].size(), i));
FOR(i, 0, n) {
pii p = *S.begin();
S.erase(*S.begin());
ans = max(ans, calc(p.sc));
}
cout << ans << '\n';
}
int32_t main() {
cin.tie(0) -> sync_with_stdio(false);
cin.exceptions(cin.failbit);
miku();
return 0;
}
Compilation message
politicaldevelopment.cpp: In function 'long long int calc(long long int)':
politicaldevelopment.cpp:11:20: warning: statement has no effect [-Wunused-value]
11 | #define debug(...) 39
| ^~
politicaldevelopment.cpp:36:5: note: in expansion of macro 'debug'
36 | debug(id);
| ^~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1628 KB |
Output is correct |
2 |
Correct |
1 ms |
1628 KB |
Output is correct |
3 |
Correct |
5 ms |
2396 KB |
Output is correct |
4 |
Correct |
4 ms |
2396 KB |
Output is correct |
5 |
Correct |
5 ms |
2648 KB |
Output is correct |
6 |
Correct |
5 ms |
2652 KB |
Output is correct |
7 |
Correct |
5 ms |
2676 KB |
Output is correct |
8 |
Correct |
2 ms |
1884 KB |
Output is correct |
9 |
Correct |
1 ms |
1636 KB |
Output is correct |
10 |
Correct |
3 ms |
1880 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1628 KB |
Output is correct |
2 |
Correct |
1 ms |
1628 KB |
Output is correct |
3 |
Correct |
5 ms |
2396 KB |
Output is correct |
4 |
Correct |
4 ms |
2396 KB |
Output is correct |
5 |
Correct |
5 ms |
2648 KB |
Output is correct |
6 |
Correct |
5 ms |
2652 KB |
Output is correct |
7 |
Correct |
5 ms |
2676 KB |
Output is correct |
8 |
Correct |
2 ms |
1884 KB |
Output is correct |
9 |
Correct |
1 ms |
1636 KB |
Output is correct |
10 |
Correct |
3 ms |
1880 KB |
Output is correct |
11 |
Correct |
5 ms |
2396 KB |
Output is correct |
12 |
Correct |
4 ms |
2652 KB |
Output is correct |
13 |
Correct |
1 ms |
1628 KB |
Output is correct |
14 |
Correct |
4 ms |
2652 KB |
Output is correct |
15 |
Correct |
1 ms |
1584 KB |
Output is correct |
16 |
Correct |
5 ms |
2652 KB |
Output is correct |
17 |
Correct |
1 ms |
1628 KB |
Output is correct |
18 |
Correct |
5 ms |
2652 KB |
Output is correct |
19 |
Correct |
2 ms |
1884 KB |
Output is correct |
20 |
Correct |
3 ms |
2140 KB |
Output is correct |
21 |
Correct |
3 ms |
2164 KB |
Output is correct |
22 |
Correct |
2 ms |
1880 KB |
Output is correct |
23 |
Correct |
6 ms |
2648 KB |
Output is correct |
24 |
Correct |
2 ms |
1884 KB |
Output is correct |
25 |
Correct |
6 ms |
2652 KB |
Output is correct |
26 |
Correct |
6 ms |
2652 KB |
Output is correct |
27 |
Correct |
5 ms |
2412 KB |
Output is correct |
28 |
Correct |
6 ms |
2652 KB |
Output is correct |
29 |
Correct |
5 ms |
2396 KB |
Output is correct |
30 |
Correct |
6 ms |
2652 KB |
Output is correct |
31 |
Correct |
6 ms |
2652 KB |
Output is correct |
32 |
Correct |
5 ms |
2652 KB |
Output is correct |
33 |
Correct |
6 ms |
2712 KB |
Output is correct |
34 |
Correct |
6 ms |
2672 KB |
Output is correct |
35 |
Correct |
4 ms |
2140 KB |
Output is correct |
36 |
Correct |
3 ms |
2160 KB |
Output is correct |
37 |
Correct |
3 ms |
2140 KB |
Output is correct |
38 |
Correct |
3 ms |
2008 KB |
Output is correct |
39 |
Correct |
2 ms |
1884 KB |
Output is correct |
40 |
Correct |
9 ms |
3164 KB |
Output is correct |
41 |
Correct |
2 ms |
1884 KB |
Output is correct |
42 |
Correct |
11 ms |
3164 KB |
Output is correct |
43 |
Correct |
8 ms |
3160 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1884 KB |
Output is correct |
2 |
Correct |
1 ms |
1628 KB |
Output is correct |
3 |
Correct |
1 ms |
1628 KB |
Output is correct |
4 |
Correct |
1 ms |
1628 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1628 KB |
Output is correct |
7 |
Correct |
1 ms |
1628 KB |
Output is correct |
8 |
Correct |
1 ms |
1628 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
1 ms |
1628 KB |
Output is correct |
11 |
Correct |
345 ms |
34284 KB |
Output is correct |
12 |
Correct |
1 ms |
1628 KB |
Output is correct |
13 |
Correct |
326 ms |
34500 KB |
Output is correct |
14 |
Correct |
1 ms |
1628 KB |
Output is correct |
15 |
Correct |
347 ms |
34404 KB |
Output is correct |
16 |
Correct |
347 ms |
34492 KB |
Output is correct |
17 |
Correct |
353 ms |
34492 KB |
Output is correct |
18 |
Correct |
377 ms |
34752 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1628 KB |
Output is correct |
2 |
Correct |
1 ms |
1628 KB |
Output is correct |
3 |
Correct |
5 ms |
2396 KB |
Output is correct |
4 |
Correct |
4 ms |
2396 KB |
Output is correct |
5 |
Correct |
5 ms |
2648 KB |
Output is correct |
6 |
Correct |
5 ms |
2652 KB |
Output is correct |
7 |
Correct |
5 ms |
2676 KB |
Output is correct |
8 |
Correct |
2 ms |
1884 KB |
Output is correct |
9 |
Correct |
1 ms |
1636 KB |
Output is correct |
10 |
Correct |
3 ms |
1880 KB |
Output is correct |
11 |
Correct |
5 ms |
2396 KB |
Output is correct |
12 |
Correct |
4 ms |
2652 KB |
Output is correct |
13 |
Correct |
1 ms |
1628 KB |
Output is correct |
14 |
Correct |
4 ms |
2652 KB |
Output is correct |
15 |
Correct |
1 ms |
1584 KB |
Output is correct |
16 |
Correct |
5 ms |
2652 KB |
Output is correct |
17 |
Correct |
1 ms |
1628 KB |
Output is correct |
18 |
Correct |
5 ms |
2652 KB |
Output is correct |
19 |
Correct |
2 ms |
1884 KB |
Output is correct |
20 |
Correct |
3 ms |
2140 KB |
Output is correct |
21 |
Correct |
3 ms |
2164 KB |
Output is correct |
22 |
Correct |
2 ms |
1880 KB |
Output is correct |
23 |
Correct |
6 ms |
2648 KB |
Output is correct |
24 |
Correct |
2 ms |
1884 KB |
Output is correct |
25 |
Correct |
6 ms |
2652 KB |
Output is correct |
26 |
Correct |
6 ms |
2652 KB |
Output is correct |
27 |
Correct |
5 ms |
2412 KB |
Output is correct |
28 |
Correct |
6 ms |
2652 KB |
Output is correct |
29 |
Correct |
5 ms |
2396 KB |
Output is correct |
30 |
Correct |
6 ms |
2652 KB |
Output is correct |
31 |
Correct |
6 ms |
2652 KB |
Output is correct |
32 |
Correct |
5 ms |
2652 KB |
Output is correct |
33 |
Correct |
6 ms |
2712 KB |
Output is correct |
34 |
Correct |
6 ms |
2672 KB |
Output is correct |
35 |
Correct |
4 ms |
2140 KB |
Output is correct |
36 |
Correct |
3 ms |
2160 KB |
Output is correct |
37 |
Correct |
3 ms |
2140 KB |
Output is correct |
38 |
Correct |
3 ms |
2008 KB |
Output is correct |
39 |
Correct |
2 ms |
1884 KB |
Output is correct |
40 |
Correct |
9 ms |
3164 KB |
Output is correct |
41 |
Correct |
2 ms |
1884 KB |
Output is correct |
42 |
Correct |
11 ms |
3164 KB |
Output is correct |
43 |
Correct |
8 ms |
3160 KB |
Output is correct |
44 |
Correct |
14 ms |
4024 KB |
Output is correct |
45 |
Correct |
1 ms |
1624 KB |
Output is correct |
46 |
Correct |
9 ms |
2980 KB |
Output is correct |
47 |
Correct |
16 ms |
4276 KB |
Output is correct |
48 |
Correct |
8 ms |
3164 KB |
Output is correct |
49 |
Correct |
16 ms |
4172 KB |
Output is correct |
50 |
Correct |
16 ms |
4024 KB |
Output is correct |
51 |
Correct |
35 ms |
6508 KB |
Output is correct |
52 |
Correct |
4 ms |
2396 KB |
Output is correct |
53 |
Correct |
28 ms |
7816 KB |
Output is correct |
54 |
Correct |
39 ms |
7772 KB |
Output is correct |
55 |
Correct |
5 ms |
2652 KB |
Output is correct |
56 |
Correct |
4 ms |
2484 KB |
Output is correct |
57 |
Correct |
2 ms |
1880 KB |
Output is correct |
58 |
Correct |
29 ms |
7632 KB |
Output is correct |
59 |
Correct |
9 ms |
2908 KB |
Output is correct |
60 |
Correct |
5 ms |
2652 KB |
Output is correct |
61 |
Correct |
7 ms |
2904 KB |
Output is correct |
62 |
Correct |
7 ms |
2908 KB |
Output is correct |
63 |
Correct |
14 ms |
4024 KB |
Output is correct |
64 |
Correct |
12 ms |
3768 KB |
Output is correct |
65 |
Correct |
8 ms |
2908 KB |
Output is correct |
66 |
Correct |
7 ms |
2944 KB |
Output is correct |
67 |
Correct |
19 ms |
4812 KB |
Output is correct |
68 |
Correct |
13 ms |
3764 KB |
Output is correct |
69 |
Correct |
9 ms |
2904 KB |
Output is correct |
70 |
Correct |
14 ms |
4024 KB |
Output is correct |
71 |
Correct |
20 ms |
4716 KB |
Output is correct |
72 |
Correct |
19 ms |
4716 KB |
Output is correct |
73 |
Correct |
5 ms |
2396 KB |
Output is correct |
74 |
Correct |
15 ms |
4020 KB |
Output is correct |
75 |
Correct |
18 ms |
4712 KB |
Output is correct |
76 |
Correct |
11 ms |
3764 KB |
Output is correct |
77 |
Correct |
23 ms |
5224 KB |
Output is correct |
78 |
Correct |
5 ms |
2396 KB |
Output is correct |
79 |
Correct |
13 ms |
3512 KB |
Output is correct |
80 |
Correct |
13 ms |
3512 KB |
Output is correct |
81 |
Correct |
23 ms |
5224 KB |
Output is correct |
82 |
Correct |
2 ms |
1884 KB |
Output is correct |
83 |
Correct |
12 ms |
3508 KB |
Output is correct |
84 |
Correct |
19 ms |
5224 KB |
Output is correct |
85 |
Correct |
2 ms |
1884 KB |
Output is correct |
86 |
Correct |
18 ms |
4872 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1628 KB |
Output is correct |
2 |
Correct |
1 ms |
1628 KB |
Output is correct |
3 |
Correct |
5 ms |
2396 KB |
Output is correct |
4 |
Correct |
4 ms |
2396 KB |
Output is correct |
5 |
Correct |
5 ms |
2648 KB |
Output is correct |
6 |
Correct |
5 ms |
2652 KB |
Output is correct |
7 |
Correct |
5 ms |
2676 KB |
Output is correct |
8 |
Correct |
2 ms |
1884 KB |
Output is correct |
9 |
Correct |
1 ms |
1636 KB |
Output is correct |
10 |
Correct |
3 ms |
1880 KB |
Output is correct |
11 |
Correct |
5 ms |
2396 KB |
Output is correct |
12 |
Correct |
4 ms |
2652 KB |
Output is correct |
13 |
Correct |
1 ms |
1628 KB |
Output is correct |
14 |
Correct |
4 ms |
2652 KB |
Output is correct |
15 |
Correct |
1 ms |
1584 KB |
Output is correct |
16 |
Correct |
5 ms |
2652 KB |
Output is correct |
17 |
Correct |
1 ms |
1628 KB |
Output is correct |
18 |
Correct |
5 ms |
2652 KB |
Output is correct |
19 |
Correct |
2 ms |
1884 KB |
Output is correct |
20 |
Correct |
3 ms |
2140 KB |
Output is correct |
21 |
Correct |
3 ms |
2164 KB |
Output is correct |
22 |
Correct |
2 ms |
1880 KB |
Output is correct |
23 |
Correct |
6 ms |
2648 KB |
Output is correct |
24 |
Correct |
2 ms |
1884 KB |
Output is correct |
25 |
Correct |
6 ms |
2652 KB |
Output is correct |
26 |
Correct |
6 ms |
2652 KB |
Output is correct |
27 |
Correct |
5 ms |
2412 KB |
Output is correct |
28 |
Correct |
6 ms |
2652 KB |
Output is correct |
29 |
Correct |
5 ms |
2396 KB |
Output is correct |
30 |
Correct |
6 ms |
2652 KB |
Output is correct |
31 |
Correct |
6 ms |
2652 KB |
Output is correct |
32 |
Correct |
5 ms |
2652 KB |
Output is correct |
33 |
Correct |
6 ms |
2712 KB |
Output is correct |
34 |
Correct |
6 ms |
2672 KB |
Output is correct |
35 |
Correct |
4 ms |
2140 KB |
Output is correct |
36 |
Correct |
3 ms |
2160 KB |
Output is correct |
37 |
Correct |
3 ms |
2140 KB |
Output is correct |
38 |
Correct |
3 ms |
2008 KB |
Output is correct |
39 |
Correct |
2 ms |
1884 KB |
Output is correct |
40 |
Correct |
9 ms |
3164 KB |
Output is correct |
41 |
Correct |
2 ms |
1884 KB |
Output is correct |
42 |
Correct |
11 ms |
3164 KB |
Output is correct |
43 |
Correct |
8 ms |
3160 KB |
Output is correct |
44 |
Correct |
1 ms |
1628 KB |
Output is correct |
45 |
Correct |
217 ms |
22784 KB |
Output is correct |
46 |
Correct |
67 ms |
14264 KB |
Output is correct |
47 |
Correct |
191 ms |
22816 KB |
Output is correct |
48 |
Correct |
173 ms |
22864 KB |
Output is correct |
49 |
Correct |
40 ms |
12228 KB |
Output is correct |
50 |
Correct |
164 ms |
29780 KB |
Output is correct |
51 |
Correct |
211 ms |
22900 KB |
Output is correct |
52 |
Correct |
50 ms |
12228 KB |
Output is correct |
53 |
Correct |
40 ms |
12240 KB |
Output is correct |
54 |
Correct |
15 ms |
5208 KB |
Output is correct |
55 |
Correct |
153 ms |
29376 KB |
Output is correct |
56 |
Correct |
31 ms |
9316 KB |
Output is correct |
57 |
Correct |
46 ms |
12104 KB |
Output is correct |
58 |
Correct |
73 ms |
14276 KB |
Output is correct |
59 |
Correct |
33 ms |
9164 KB |
Output is correct |
60 |
Correct |
31 ms |
9324 KB |
Output is correct |
61 |
Correct |
68 ms |
14288 KB |
Output is correct |
62 |
Correct |
62 ms |
11724 KB |
Output is correct |
63 |
Correct |
129 ms |
16872 KB |
Output is correct |
64 |
Correct |
32 ms |
9244 KB |
Output is correct |
65 |
Correct |
130 ms |
19328 KB |
Output is correct |
66 |
Correct |
48 ms |
11716 KB |
Output is correct |
67 |
Correct |
122 ms |
17020 KB |
Output is correct |
68 |
Correct |
125 ms |
18732 KB |
Output is correct |
69 |
Correct |
130 ms |
19328 KB |
Output is correct |
70 |
Correct |
51 ms |
11724 KB |
Output is correct |
71 |
Correct |
138 ms |
18652 KB |
Output is correct |
72 |
Correct |
82 ms |
15040 KB |
Output is correct |
73 |
Correct |
153 ms |
20600 KB |
Output is correct |
74 |
Correct |
50 ms |
11716 KB |
Output is correct |
75 |
Correct |
50 ms |
9672 KB |
Output is correct |
76 |
Correct |
99 ms |
15244 KB |
Output is correct |
77 |
Correct |
154 ms |
20604 KB |
Output is correct |
78 |
Correct |
71 ms |
11172 KB |
Output is correct |
79 |
Correct |
50 ms |
9508 KB |
Output is correct |
80 |
Correct |
20 ms |
5480 KB |
Output is correct |
81 |
Correct |
78 ms |
10984 KB |
Output is correct |
82 |
Correct |
126 ms |
17568 KB |
Output is correct |
83 |
Correct |
19 ms |
5484 KB |
Output is correct |
84 |
Correct |
119 ms |
17720 KB |
Output is correct |