// ?
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define X first
#define Y second
#define sep ' '
#define endl '\n'
#define debug(x) cerr << #x << ": " << x << endl;
const ll MAXN = 1e6 + 10;
set<int> adj[MAXN];
set<pll> st;
int n, k, ans = 1, msk_adj[MAXN];
bool dp[MAXN];
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n >> k;
for (int i = 1; i <= n; i++) {
int d;
cin >> d;
for (int j = 1; j <= d; j++) {
int v;
cin >> v;
v++;
adj[i].insert(v);
}
st.insert({adj[i].size(), i});
}
while (!st.empty()) {
int v = st.begin() -> Y;
st.erase(st.begin());
vector<int> vec;
for (int e : adj[v]) {
st.erase({adj[e].size(), e});
adj[e].erase(v);
vec.push_back(e);
st.insert({adj[e].size(), e});
}
int sz = vec.size();
for (int i = 0; i < sz; i++)
for (int j = 0; j < sz; j++)
msk_adj[i] ^= (adj[vec[i]].find(vec[j]) == adj[vec[i]].end() ? 0 : (1 << j));
dp[0] = true;
for (int msk = 1; msk < (1 << sz); msk++) {
int ind = __builtin_ctz(msk), tmsk = msk - (1 << ind);
dp[msk] = (dp[tmsk] && (tmsk & msk_adj[ind]) == tmsk);
if (dp[msk]) ans = max(ans, __builtin_popcount(msk) + 1);
}
}
cout << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
47184 KB |
Output is correct |
2 |
Correct |
24 ms |
47304 KB |
Output is correct |
3 |
Correct |
29 ms |
48028 KB |
Output is correct |
4 |
Correct |
30 ms |
48072 KB |
Output is correct |
5 |
Correct |
30 ms |
48072 KB |
Output is correct |
6 |
Correct |
33 ms |
48080 KB |
Output is correct |
7 |
Correct |
30 ms |
48048 KB |
Output is correct |
8 |
Correct |
26 ms |
47548 KB |
Output is correct |
9 |
Correct |
25 ms |
47184 KB |
Output is correct |
10 |
Correct |
29 ms |
47512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
47184 KB |
Output is correct |
2 |
Correct |
24 ms |
47304 KB |
Output is correct |
3 |
Correct |
29 ms |
48028 KB |
Output is correct |
4 |
Correct |
30 ms |
48072 KB |
Output is correct |
5 |
Correct |
30 ms |
48072 KB |
Output is correct |
6 |
Correct |
33 ms |
48080 KB |
Output is correct |
7 |
Correct |
30 ms |
48048 KB |
Output is correct |
8 |
Correct |
26 ms |
47548 KB |
Output is correct |
9 |
Correct |
25 ms |
47184 KB |
Output is correct |
10 |
Correct |
29 ms |
47512 KB |
Output is correct |
11 |
Correct |
31 ms |
48104 KB |
Output is correct |
12 |
Correct |
27 ms |
48080 KB |
Output is correct |
13 |
Correct |
25 ms |
47256 KB |
Output is correct |
14 |
Correct |
31 ms |
48144 KB |
Output is correct |
15 |
Correct |
25 ms |
47228 KB |
Output is correct |
16 |
Correct |
36 ms |
48068 KB |
Output is correct |
17 |
Correct |
24 ms |
47196 KB |
Output is correct |
18 |
Correct |
31 ms |
48048 KB |
Output is correct |
19 |
Correct |
27 ms |
47560 KB |
Output is correct |
20 |
Correct |
28 ms |
47804 KB |
Output is correct |
21 |
Correct |
27 ms |
47820 KB |
Output is correct |
22 |
Correct |
28 ms |
47532 KB |
Output is correct |
23 |
Correct |
30 ms |
48208 KB |
Output is correct |
24 |
Correct |
28 ms |
47560 KB |
Output is correct |
25 |
Correct |
32 ms |
48208 KB |
Output is correct |
26 |
Correct |
34 ms |
48072 KB |
Output is correct |
27 |
Correct |
28 ms |
48104 KB |
Output is correct |
28 |
Correct |
34 ms |
48188 KB |
Output is correct |
29 |
Correct |
29 ms |
48044 KB |
Output is correct |
30 |
Correct |
36 ms |
48308 KB |
Output is correct |
31 |
Correct |
32 ms |
48232 KB |
Output is correct |
32 |
Correct |
35 ms |
48208 KB |
Output is correct |
33 |
Correct |
29 ms |
48284 KB |
Output is correct |
34 |
Correct |
30 ms |
48196 KB |
Output is correct |
35 |
Correct |
27 ms |
47760 KB |
Output is correct |
36 |
Correct |
29 ms |
47772 KB |
Output is correct |
37 |
Correct |
27 ms |
47696 KB |
Output is correct |
38 |
Correct |
27 ms |
47508 KB |
Output is correct |
39 |
Correct |
25 ms |
47600 KB |
Output is correct |
40 |
Correct |
35 ms |
48592 KB |
Output is correct |
41 |
Correct |
30 ms |
47576 KB |
Output is correct |
42 |
Correct |
35 ms |
48840 KB |
Output is correct |
43 |
Correct |
37 ms |
48756 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
47548 KB |
Output is correct |
2 |
Correct |
26 ms |
47304 KB |
Output is correct |
3 |
Correct |
27 ms |
47224 KB |
Output is correct |
4 |
Correct |
27 ms |
47232 KB |
Output is correct |
5 |
Correct |
27 ms |
47288 KB |
Output is correct |
6 |
Incorrect |
24 ms |
47220 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
47184 KB |
Output is correct |
2 |
Correct |
24 ms |
47304 KB |
Output is correct |
3 |
Correct |
29 ms |
48028 KB |
Output is correct |
4 |
Correct |
30 ms |
48072 KB |
Output is correct |
5 |
Correct |
30 ms |
48072 KB |
Output is correct |
6 |
Correct |
33 ms |
48080 KB |
Output is correct |
7 |
Correct |
30 ms |
48048 KB |
Output is correct |
8 |
Correct |
26 ms |
47548 KB |
Output is correct |
9 |
Correct |
25 ms |
47184 KB |
Output is correct |
10 |
Correct |
29 ms |
47512 KB |
Output is correct |
11 |
Correct |
31 ms |
48104 KB |
Output is correct |
12 |
Correct |
27 ms |
48080 KB |
Output is correct |
13 |
Correct |
25 ms |
47256 KB |
Output is correct |
14 |
Correct |
31 ms |
48144 KB |
Output is correct |
15 |
Correct |
25 ms |
47228 KB |
Output is correct |
16 |
Correct |
36 ms |
48068 KB |
Output is correct |
17 |
Correct |
24 ms |
47196 KB |
Output is correct |
18 |
Correct |
31 ms |
48048 KB |
Output is correct |
19 |
Correct |
27 ms |
47560 KB |
Output is correct |
20 |
Correct |
28 ms |
47804 KB |
Output is correct |
21 |
Correct |
27 ms |
47820 KB |
Output is correct |
22 |
Correct |
28 ms |
47532 KB |
Output is correct |
23 |
Correct |
30 ms |
48208 KB |
Output is correct |
24 |
Correct |
28 ms |
47560 KB |
Output is correct |
25 |
Correct |
32 ms |
48208 KB |
Output is correct |
26 |
Correct |
34 ms |
48072 KB |
Output is correct |
27 |
Correct |
28 ms |
48104 KB |
Output is correct |
28 |
Correct |
34 ms |
48188 KB |
Output is correct |
29 |
Correct |
29 ms |
48044 KB |
Output is correct |
30 |
Correct |
36 ms |
48308 KB |
Output is correct |
31 |
Correct |
32 ms |
48232 KB |
Output is correct |
32 |
Correct |
35 ms |
48208 KB |
Output is correct |
33 |
Correct |
29 ms |
48284 KB |
Output is correct |
34 |
Correct |
30 ms |
48196 KB |
Output is correct |
35 |
Correct |
27 ms |
47760 KB |
Output is correct |
36 |
Correct |
29 ms |
47772 KB |
Output is correct |
37 |
Correct |
27 ms |
47696 KB |
Output is correct |
38 |
Correct |
27 ms |
47508 KB |
Output is correct |
39 |
Correct |
25 ms |
47600 KB |
Output is correct |
40 |
Correct |
35 ms |
48592 KB |
Output is correct |
41 |
Correct |
30 ms |
47576 KB |
Output is correct |
42 |
Correct |
35 ms |
48840 KB |
Output is correct |
43 |
Correct |
37 ms |
48756 KB |
Output is correct |
44 |
Incorrect |
44 ms |
49752 KB |
Output isn't correct |
45 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
47184 KB |
Output is correct |
2 |
Correct |
24 ms |
47304 KB |
Output is correct |
3 |
Correct |
29 ms |
48028 KB |
Output is correct |
4 |
Correct |
30 ms |
48072 KB |
Output is correct |
5 |
Correct |
30 ms |
48072 KB |
Output is correct |
6 |
Correct |
33 ms |
48080 KB |
Output is correct |
7 |
Correct |
30 ms |
48048 KB |
Output is correct |
8 |
Correct |
26 ms |
47548 KB |
Output is correct |
9 |
Correct |
25 ms |
47184 KB |
Output is correct |
10 |
Correct |
29 ms |
47512 KB |
Output is correct |
11 |
Correct |
31 ms |
48104 KB |
Output is correct |
12 |
Correct |
27 ms |
48080 KB |
Output is correct |
13 |
Correct |
25 ms |
47256 KB |
Output is correct |
14 |
Correct |
31 ms |
48144 KB |
Output is correct |
15 |
Correct |
25 ms |
47228 KB |
Output is correct |
16 |
Correct |
36 ms |
48068 KB |
Output is correct |
17 |
Correct |
24 ms |
47196 KB |
Output is correct |
18 |
Correct |
31 ms |
48048 KB |
Output is correct |
19 |
Correct |
27 ms |
47560 KB |
Output is correct |
20 |
Correct |
28 ms |
47804 KB |
Output is correct |
21 |
Correct |
27 ms |
47820 KB |
Output is correct |
22 |
Correct |
28 ms |
47532 KB |
Output is correct |
23 |
Correct |
30 ms |
48208 KB |
Output is correct |
24 |
Correct |
28 ms |
47560 KB |
Output is correct |
25 |
Correct |
32 ms |
48208 KB |
Output is correct |
26 |
Correct |
34 ms |
48072 KB |
Output is correct |
27 |
Correct |
28 ms |
48104 KB |
Output is correct |
28 |
Correct |
34 ms |
48188 KB |
Output is correct |
29 |
Correct |
29 ms |
48044 KB |
Output is correct |
30 |
Correct |
36 ms |
48308 KB |
Output is correct |
31 |
Correct |
32 ms |
48232 KB |
Output is correct |
32 |
Correct |
35 ms |
48208 KB |
Output is correct |
33 |
Correct |
29 ms |
48284 KB |
Output is correct |
34 |
Correct |
30 ms |
48196 KB |
Output is correct |
35 |
Correct |
27 ms |
47760 KB |
Output is correct |
36 |
Correct |
29 ms |
47772 KB |
Output is correct |
37 |
Correct |
27 ms |
47696 KB |
Output is correct |
38 |
Correct |
27 ms |
47508 KB |
Output is correct |
39 |
Correct |
25 ms |
47600 KB |
Output is correct |
40 |
Correct |
35 ms |
48592 KB |
Output is correct |
41 |
Correct |
30 ms |
47576 KB |
Output is correct |
42 |
Correct |
35 ms |
48840 KB |
Output is correct |
43 |
Correct |
37 ms |
48756 KB |
Output is correct |
44 |
Correct |
29 ms |
47208 KB |
Output is correct |
45 |
Correct |
333 ms |
66248 KB |
Output is correct |
46 |
Correct |
129 ms |
58380 KB |
Output is correct |
47 |
Correct |
292 ms |
66340 KB |
Output is correct |
48 |
Correct |
292 ms |
66304 KB |
Output is correct |
49 |
Correct |
84 ms |
55764 KB |
Output is correct |
50 |
Correct |
269 ms |
71612 KB |
Output is correct |
51 |
Correct |
288 ms |
66284 KB |
Output is correct |
52 |
Correct |
85 ms |
55752 KB |
Output is correct |
53 |
Correct |
83 ms |
55752 KB |
Output is correct |
54 |
Correct |
42 ms |
50388 KB |
Output is correct |
55 |
Correct |
306 ms |
71552 KB |
Output is correct |
56 |
Correct |
61 ms |
53072 KB |
Output is correct |
57 |
Correct |
88 ms |
55768 KB |
Output is correct |
58 |
Incorrect |
99 ms |
58472 KB |
Output isn't correct |
59 |
Halted |
0 ms |
0 KB |
- |