// ?
#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();
if (sz > k) assert(false);
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 |
28 ms |
47288 KB |
Output is correct |
2 |
Correct |
24 ms |
47204 KB |
Output is correct |
3 |
Correct |
31 ms |
48004 KB |
Output is correct |
4 |
Correct |
30 ms |
47956 KB |
Output is correct |
5 |
Correct |
32 ms |
47948 KB |
Output is correct |
6 |
Correct |
30 ms |
47948 KB |
Output is correct |
7 |
Correct |
29 ms |
48076 KB |
Output is correct |
8 |
Correct |
28 ms |
47556 KB |
Output is correct |
9 |
Correct |
25 ms |
47180 KB |
Output is correct |
10 |
Correct |
29 ms |
47608 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
47288 KB |
Output is correct |
2 |
Correct |
24 ms |
47204 KB |
Output is correct |
3 |
Correct |
31 ms |
48004 KB |
Output is correct |
4 |
Correct |
30 ms |
47956 KB |
Output is correct |
5 |
Correct |
32 ms |
47948 KB |
Output is correct |
6 |
Correct |
30 ms |
47948 KB |
Output is correct |
7 |
Correct |
29 ms |
48076 KB |
Output is correct |
8 |
Correct |
28 ms |
47556 KB |
Output is correct |
9 |
Correct |
25 ms |
47180 KB |
Output is correct |
10 |
Correct |
29 ms |
47608 KB |
Output is correct |
11 |
Correct |
28 ms |
48052 KB |
Output is correct |
12 |
Correct |
28 ms |
48076 KB |
Output is correct |
13 |
Correct |
26 ms |
47224 KB |
Output is correct |
14 |
Correct |
32 ms |
48072 KB |
Output is correct |
15 |
Correct |
26 ms |
47204 KB |
Output is correct |
16 |
Correct |
35 ms |
48136 KB |
Output is correct |
17 |
Correct |
25 ms |
47180 KB |
Output is correct |
18 |
Correct |
29 ms |
47948 KB |
Output is correct |
19 |
Correct |
26 ms |
47596 KB |
Output is correct |
20 |
Correct |
32 ms |
47800 KB |
Output is correct |
21 |
Correct |
26 ms |
47820 KB |
Output is correct |
22 |
Correct |
28 ms |
47600 KB |
Output is correct |
23 |
Correct |
35 ms |
48068 KB |
Output is correct |
24 |
Correct |
27 ms |
47564 KB |
Output is correct |
25 |
Correct |
34 ms |
48204 KB |
Output is correct |
26 |
Correct |
33 ms |
48144 KB |
Output is correct |
27 |
Correct |
31 ms |
48060 KB |
Output is correct |
28 |
Correct |
31 ms |
48168 KB |
Output is correct |
29 |
Correct |
29 ms |
48004 KB |
Output is correct |
30 |
Correct |
30 ms |
48124 KB |
Output is correct |
31 |
Correct |
34 ms |
48212 KB |
Output is correct |
32 |
Correct |
31 ms |
48224 KB |
Output is correct |
33 |
Correct |
33 ms |
48204 KB |
Output is correct |
34 |
Correct |
38 ms |
48228 KB |
Output is correct |
35 |
Correct |
27 ms |
47724 KB |
Output is correct |
36 |
Correct |
30 ms |
47704 KB |
Output is correct |
37 |
Correct |
28 ms |
47756 KB |
Output is correct |
38 |
Correct |
26 ms |
47584 KB |
Output is correct |
39 |
Correct |
27 ms |
47568 KB |
Output is correct |
40 |
Correct |
37 ms |
48460 KB |
Output is correct |
41 |
Correct |
27 ms |
47456 KB |
Output is correct |
42 |
Correct |
37 ms |
48412 KB |
Output is correct |
43 |
Correct |
34 ms |
48536 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
47564 KB |
Output is correct |
2 |
Correct |
22 ms |
47236 KB |
Output is correct |
3 |
Correct |
27 ms |
47152 KB |
Output is correct |
4 |
Correct |
24 ms |
47288 KB |
Output is correct |
5 |
Correct |
25 ms |
47180 KB |
Output is correct |
6 |
Incorrect |
27 ms |
47212 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
47288 KB |
Output is correct |
2 |
Correct |
24 ms |
47204 KB |
Output is correct |
3 |
Correct |
31 ms |
48004 KB |
Output is correct |
4 |
Correct |
30 ms |
47956 KB |
Output is correct |
5 |
Correct |
32 ms |
47948 KB |
Output is correct |
6 |
Correct |
30 ms |
47948 KB |
Output is correct |
7 |
Correct |
29 ms |
48076 KB |
Output is correct |
8 |
Correct |
28 ms |
47556 KB |
Output is correct |
9 |
Correct |
25 ms |
47180 KB |
Output is correct |
10 |
Correct |
29 ms |
47608 KB |
Output is correct |
11 |
Correct |
28 ms |
48052 KB |
Output is correct |
12 |
Correct |
28 ms |
48076 KB |
Output is correct |
13 |
Correct |
26 ms |
47224 KB |
Output is correct |
14 |
Correct |
32 ms |
48072 KB |
Output is correct |
15 |
Correct |
26 ms |
47204 KB |
Output is correct |
16 |
Correct |
35 ms |
48136 KB |
Output is correct |
17 |
Correct |
25 ms |
47180 KB |
Output is correct |
18 |
Correct |
29 ms |
47948 KB |
Output is correct |
19 |
Correct |
26 ms |
47596 KB |
Output is correct |
20 |
Correct |
32 ms |
47800 KB |
Output is correct |
21 |
Correct |
26 ms |
47820 KB |
Output is correct |
22 |
Correct |
28 ms |
47600 KB |
Output is correct |
23 |
Correct |
35 ms |
48068 KB |
Output is correct |
24 |
Correct |
27 ms |
47564 KB |
Output is correct |
25 |
Correct |
34 ms |
48204 KB |
Output is correct |
26 |
Correct |
33 ms |
48144 KB |
Output is correct |
27 |
Correct |
31 ms |
48060 KB |
Output is correct |
28 |
Correct |
31 ms |
48168 KB |
Output is correct |
29 |
Correct |
29 ms |
48004 KB |
Output is correct |
30 |
Correct |
30 ms |
48124 KB |
Output is correct |
31 |
Correct |
34 ms |
48212 KB |
Output is correct |
32 |
Correct |
31 ms |
48224 KB |
Output is correct |
33 |
Correct |
33 ms |
48204 KB |
Output is correct |
34 |
Correct |
38 ms |
48228 KB |
Output is correct |
35 |
Correct |
27 ms |
47724 KB |
Output is correct |
36 |
Correct |
30 ms |
47704 KB |
Output is correct |
37 |
Correct |
28 ms |
47756 KB |
Output is correct |
38 |
Correct |
26 ms |
47584 KB |
Output is correct |
39 |
Correct |
27 ms |
47568 KB |
Output is correct |
40 |
Correct |
37 ms |
48460 KB |
Output is correct |
41 |
Correct |
27 ms |
47456 KB |
Output is correct |
42 |
Correct |
37 ms |
48412 KB |
Output is correct |
43 |
Correct |
34 ms |
48536 KB |
Output is correct |
44 |
Incorrect |
41 ms |
49468 KB |
Output isn't correct |
45 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
47288 KB |
Output is correct |
2 |
Correct |
24 ms |
47204 KB |
Output is correct |
3 |
Correct |
31 ms |
48004 KB |
Output is correct |
4 |
Correct |
30 ms |
47956 KB |
Output is correct |
5 |
Correct |
32 ms |
47948 KB |
Output is correct |
6 |
Correct |
30 ms |
47948 KB |
Output is correct |
7 |
Correct |
29 ms |
48076 KB |
Output is correct |
8 |
Correct |
28 ms |
47556 KB |
Output is correct |
9 |
Correct |
25 ms |
47180 KB |
Output is correct |
10 |
Correct |
29 ms |
47608 KB |
Output is correct |
11 |
Correct |
28 ms |
48052 KB |
Output is correct |
12 |
Correct |
28 ms |
48076 KB |
Output is correct |
13 |
Correct |
26 ms |
47224 KB |
Output is correct |
14 |
Correct |
32 ms |
48072 KB |
Output is correct |
15 |
Correct |
26 ms |
47204 KB |
Output is correct |
16 |
Correct |
35 ms |
48136 KB |
Output is correct |
17 |
Correct |
25 ms |
47180 KB |
Output is correct |
18 |
Correct |
29 ms |
47948 KB |
Output is correct |
19 |
Correct |
26 ms |
47596 KB |
Output is correct |
20 |
Correct |
32 ms |
47800 KB |
Output is correct |
21 |
Correct |
26 ms |
47820 KB |
Output is correct |
22 |
Correct |
28 ms |
47600 KB |
Output is correct |
23 |
Correct |
35 ms |
48068 KB |
Output is correct |
24 |
Correct |
27 ms |
47564 KB |
Output is correct |
25 |
Correct |
34 ms |
48204 KB |
Output is correct |
26 |
Correct |
33 ms |
48144 KB |
Output is correct |
27 |
Correct |
31 ms |
48060 KB |
Output is correct |
28 |
Correct |
31 ms |
48168 KB |
Output is correct |
29 |
Correct |
29 ms |
48004 KB |
Output is correct |
30 |
Correct |
30 ms |
48124 KB |
Output is correct |
31 |
Correct |
34 ms |
48212 KB |
Output is correct |
32 |
Correct |
31 ms |
48224 KB |
Output is correct |
33 |
Correct |
33 ms |
48204 KB |
Output is correct |
34 |
Correct |
38 ms |
48228 KB |
Output is correct |
35 |
Correct |
27 ms |
47724 KB |
Output is correct |
36 |
Correct |
30 ms |
47704 KB |
Output is correct |
37 |
Correct |
28 ms |
47756 KB |
Output is correct |
38 |
Correct |
26 ms |
47584 KB |
Output is correct |
39 |
Correct |
27 ms |
47568 KB |
Output is correct |
40 |
Correct |
37 ms |
48460 KB |
Output is correct |
41 |
Correct |
27 ms |
47456 KB |
Output is correct |
42 |
Correct |
37 ms |
48412 KB |
Output is correct |
43 |
Correct |
34 ms |
48536 KB |
Output is correct |
44 |
Correct |
28 ms |
47180 KB |
Output is correct |
45 |
Correct |
276 ms |
64452 KB |
Output is correct |
46 |
Correct |
138 ms |
57448 KB |
Output is correct |
47 |
Correct |
280 ms |
64428 KB |
Output is correct |
48 |
Correct |
278 ms |
64500 KB |
Output is correct |
49 |
Correct |
84 ms |
55012 KB |
Output is correct |
50 |
Correct |
293 ms |
69116 KB |
Output is correct |
51 |
Correct |
285 ms |
64584 KB |
Output is correct |
52 |
Correct |
85 ms |
55104 KB |
Output is correct |
53 |
Correct |
86 ms |
55128 KB |
Output is correct |
54 |
Correct |
41 ms |
50400 KB |
Output is correct |
55 |
Correct |
314 ms |
69188 KB |
Output is correct |
56 |
Correct |
62 ms |
52692 KB |
Output is correct |
57 |
Correct |
85 ms |
55000 KB |
Output is correct |
58 |
Incorrect |
98 ms |
57436 KB |
Output isn't correct |
59 |
Halted |
0 ms |
0 KB |
- |