#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44
/*const int MOD = (int) 1e9 + 7;
inline int lgput(int a, int b) {
int ans = 1;
while(b > 0) {
if(b & 1) ans = (1LL * ans * a) % MOD;
b >>= 1;
a = (1LL * a * a) % MOD;
}
return ans;
}
inline void mod(int &x) {
if(x >= MOD)
x -= MOD;
}
inline void add(int &x, int y) {
x += y;
mod(x);
}
inline void sub(int &x, int y) {
x += MOD - y;
mod(x);
}
inline void mul(int &x, int y) {
x = (1LL * x * y) % MOD;
}*/
/*int fact[], invfact[];
inline void prec(int n) {
fact[0] = 1;
for(int i = 1; i <= n; i++) {
fact[i] = (1LL * fact[i - 1] * i) % MOD;
}
invfact[n] = lgput(fact[n], MOD - 2);
for(int i = n - 1; i >= 0; i--) {
invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
}
}
inline int comb(int n, int k) {
if(n < k) return 0;
return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}*/
using namespace std;
const int MAXN = 50000;
set <int> g[MAXN + 1];
bool vis[MAXN + 1];
int main() {
//ifstream cin("A.in");
//ofstream cout("A.out");
int i, n, k;
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n >> k;
for(i = 1; i <= n; i++) {
int sz;
cin >> sz;
while(sz--) {
int nod;
cin >> nod;
g[i].insert(nod + 1);
}
}
set < pair <int, int> > Q;
for(i = 1; i <= n; i++) {
Q.insert({g[i].size(), i});
}
int ans = 1;
while(Q.size()) {
int nod = Q.begin() -> second;
Q.erase(Q.begin());
vector <int> nodes;
for(auto it : g[nod]) {
nodes.push_back(it);
}
int sz = nodes.size();
for(int conf = 0; conf < (1 << sz); conf++) {
int num = __builtin_popcount(conf);
if(num >= k || num < ans) {
continue;
}
vector <int> cur;
for(i = 0; i < sz; i++) {
if(conf & (1 << i)) {
vis[nodes[i]] = 1;
cur.push_back(nodes[i]);
}
}
bool ok = 1;
for(auto it : cur) {
for(auto itr : cur) {
if(it != itr && g[it].find(itr) == g[it].end()) {
ok = 0;
break;
}
}
if(!ok) {
break;
}
}
if(ok) {
ans = max(ans, num + 1);
}
for(auto it : cur) {
vis[it] = 0;
}
}
for(auto it : g[nod]) {
Q.erase({g[it].size(), it});
g[it].erase(nod);
Q.insert({g[it].size(), it});
}
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2684 KB |
Output is correct |
2 |
Correct |
4 ms |
2680 KB |
Output is correct |
3 |
Correct |
10 ms |
3448 KB |
Output is correct |
4 |
Correct |
10 ms |
3448 KB |
Output is correct |
5 |
Correct |
10 ms |
3448 KB |
Output is correct |
6 |
Correct |
10 ms |
3448 KB |
Output is correct |
7 |
Correct |
10 ms |
3420 KB |
Output is correct |
8 |
Correct |
9 ms |
2936 KB |
Output is correct |
9 |
Correct |
4 ms |
2680 KB |
Output is correct |
10 |
Correct |
5 ms |
2936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2684 KB |
Output is correct |
2 |
Correct |
4 ms |
2680 KB |
Output is correct |
3 |
Correct |
10 ms |
3448 KB |
Output is correct |
4 |
Correct |
10 ms |
3448 KB |
Output is correct |
5 |
Correct |
10 ms |
3448 KB |
Output is correct |
6 |
Correct |
10 ms |
3448 KB |
Output is correct |
7 |
Correct |
10 ms |
3420 KB |
Output is correct |
8 |
Correct |
9 ms |
2936 KB |
Output is correct |
9 |
Correct |
4 ms |
2680 KB |
Output is correct |
10 |
Correct |
5 ms |
2936 KB |
Output is correct |
11 |
Correct |
10 ms |
3448 KB |
Output is correct |
12 |
Correct |
11 ms |
3448 KB |
Output is correct |
13 |
Correct |
4 ms |
2680 KB |
Output is correct |
14 |
Correct |
12 ms |
3424 KB |
Output is correct |
15 |
Correct |
5 ms |
2808 KB |
Output is correct |
16 |
Correct |
10 ms |
3448 KB |
Output is correct |
17 |
Correct |
5 ms |
2680 KB |
Output is correct |
18 |
Correct |
10 ms |
3448 KB |
Output is correct |
19 |
Correct |
6 ms |
2936 KB |
Output is correct |
20 |
Correct |
9 ms |
3192 KB |
Output is correct |
21 |
Correct |
8 ms |
3196 KB |
Output is correct |
22 |
Correct |
7 ms |
2936 KB |
Output is correct |
23 |
Correct |
12 ms |
3704 KB |
Output is correct |
24 |
Correct |
5 ms |
2936 KB |
Output is correct |
25 |
Correct |
11 ms |
3576 KB |
Output is correct |
26 |
Correct |
11 ms |
3576 KB |
Output is correct |
27 |
Correct |
9 ms |
3448 KB |
Output is correct |
28 |
Correct |
11 ms |
3576 KB |
Output is correct |
29 |
Correct |
9 ms |
3448 KB |
Output is correct |
30 |
Correct |
15 ms |
3704 KB |
Output is correct |
31 |
Correct |
12 ms |
3704 KB |
Output is correct |
32 |
Correct |
12 ms |
3580 KB |
Output is correct |
33 |
Correct |
11 ms |
3704 KB |
Output is correct |
34 |
Correct |
12 ms |
3704 KB |
Output is correct |
35 |
Correct |
8 ms |
3192 KB |
Output is correct |
36 |
Correct |
8 ms |
3196 KB |
Output is correct |
37 |
Correct |
8 ms |
3192 KB |
Output is correct |
38 |
Correct |
7 ms |
3064 KB |
Output is correct |
39 |
Correct |
7 ms |
2936 KB |
Output is correct |
40 |
Correct |
16 ms |
3960 KB |
Output is correct |
41 |
Correct |
7 ms |
2936 KB |
Output is correct |
42 |
Correct |
16 ms |
3960 KB |
Output is correct |
43 |
Correct |
16 ms |
3960 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2936 KB |
Output is correct |
2 |
Correct |
5 ms |
2680 KB |
Output is correct |
3 |
Correct |
5 ms |
2684 KB |
Output is correct |
4 |
Correct |
5 ms |
2680 KB |
Output is correct |
5 |
Correct |
4 ms |
2680 KB |
Output is correct |
6 |
Correct |
4 ms |
2680 KB |
Output is correct |
7 |
Correct |
5 ms |
2808 KB |
Output is correct |
8 |
Correct |
4 ms |
2680 KB |
Output is correct |
9 |
Correct |
5 ms |
2680 KB |
Output is correct |
10 |
Correct |
4 ms |
2684 KB |
Output is correct |
11 |
Correct |
896 ms |
28912 KB |
Output is correct |
12 |
Correct |
7 ms |
2808 KB |
Output is correct |
13 |
Correct |
787 ms |
28896 KB |
Output is correct |
14 |
Correct |
4 ms |
2680 KB |
Output is correct |
15 |
Correct |
759 ms |
29048 KB |
Output is correct |
16 |
Correct |
750 ms |
28772 KB |
Output is correct |
17 |
Correct |
756 ms |
29020 KB |
Output is correct |
18 |
Correct |
757 ms |
28920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2684 KB |
Output is correct |
2 |
Correct |
4 ms |
2680 KB |
Output is correct |
3 |
Correct |
10 ms |
3448 KB |
Output is correct |
4 |
Correct |
10 ms |
3448 KB |
Output is correct |
5 |
Correct |
10 ms |
3448 KB |
Output is correct |
6 |
Correct |
10 ms |
3448 KB |
Output is correct |
7 |
Correct |
10 ms |
3420 KB |
Output is correct |
8 |
Correct |
9 ms |
2936 KB |
Output is correct |
9 |
Correct |
4 ms |
2680 KB |
Output is correct |
10 |
Correct |
5 ms |
2936 KB |
Output is correct |
11 |
Correct |
10 ms |
3448 KB |
Output is correct |
12 |
Correct |
11 ms |
3448 KB |
Output is correct |
13 |
Correct |
4 ms |
2680 KB |
Output is correct |
14 |
Correct |
12 ms |
3424 KB |
Output is correct |
15 |
Correct |
5 ms |
2808 KB |
Output is correct |
16 |
Correct |
10 ms |
3448 KB |
Output is correct |
17 |
Correct |
5 ms |
2680 KB |
Output is correct |
18 |
Correct |
10 ms |
3448 KB |
Output is correct |
19 |
Correct |
6 ms |
2936 KB |
Output is correct |
20 |
Correct |
9 ms |
3192 KB |
Output is correct |
21 |
Correct |
8 ms |
3196 KB |
Output is correct |
22 |
Correct |
7 ms |
2936 KB |
Output is correct |
23 |
Correct |
12 ms |
3704 KB |
Output is correct |
24 |
Correct |
5 ms |
2936 KB |
Output is correct |
25 |
Correct |
11 ms |
3576 KB |
Output is correct |
26 |
Correct |
11 ms |
3576 KB |
Output is correct |
27 |
Correct |
9 ms |
3448 KB |
Output is correct |
28 |
Correct |
11 ms |
3576 KB |
Output is correct |
29 |
Correct |
9 ms |
3448 KB |
Output is correct |
30 |
Correct |
15 ms |
3704 KB |
Output is correct |
31 |
Correct |
12 ms |
3704 KB |
Output is correct |
32 |
Correct |
12 ms |
3580 KB |
Output is correct |
33 |
Correct |
11 ms |
3704 KB |
Output is correct |
34 |
Correct |
12 ms |
3704 KB |
Output is correct |
35 |
Correct |
8 ms |
3192 KB |
Output is correct |
36 |
Correct |
8 ms |
3196 KB |
Output is correct |
37 |
Correct |
8 ms |
3192 KB |
Output is correct |
38 |
Correct |
7 ms |
3064 KB |
Output is correct |
39 |
Correct |
7 ms |
2936 KB |
Output is correct |
40 |
Correct |
16 ms |
3960 KB |
Output is correct |
41 |
Correct |
7 ms |
2936 KB |
Output is correct |
42 |
Correct |
16 ms |
3960 KB |
Output is correct |
43 |
Correct |
16 ms |
3960 KB |
Output is correct |
44 |
Correct |
23 ms |
4984 KB |
Output is correct |
45 |
Correct |
4 ms |
2684 KB |
Output is correct |
46 |
Correct |
16 ms |
3964 KB |
Output is correct |
47 |
Correct |
36 ms |
4984 KB |
Output is correct |
48 |
Correct |
16 ms |
3960 KB |
Output is correct |
49 |
Correct |
34 ms |
4984 KB |
Output is correct |
50 |
Correct |
37 ms |
4984 KB |
Output is correct |
51 |
Correct |
336 ms |
7032 KB |
Output is correct |
52 |
Correct |
10 ms |
3452 KB |
Output is correct |
53 |
Correct |
650 ms |
7620 KB |
Output is correct |
54 |
Correct |
669 ms |
7644 KB |
Output is correct |
55 |
Correct |
10 ms |
3448 KB |
Output is correct |
56 |
Correct |
10 ms |
3448 KB |
Output is correct |
57 |
Correct |
5 ms |
2964 KB |
Output is correct |
58 |
Correct |
655 ms |
7628 KB |
Output is correct |
59 |
Correct |
13 ms |
3960 KB |
Output is correct |
60 |
Correct |
10 ms |
3448 KB |
Output is correct |
61 |
Correct |
13 ms |
3964 KB |
Output is correct |
62 |
Correct |
15 ms |
3960 KB |
Output is correct |
63 |
Correct |
27 ms |
4984 KB |
Output is correct |
64 |
Correct |
19 ms |
4728 KB |
Output is correct |
65 |
Correct |
14 ms |
3832 KB |
Output is correct |
66 |
Correct |
13 ms |
3960 KB |
Output is correct |
67 |
Correct |
55 ms |
5396 KB |
Output is correct |
68 |
Correct |
19 ms |
4728 KB |
Output is correct |
69 |
Correct |
14 ms |
3836 KB |
Output is correct |
70 |
Correct |
26 ms |
4744 KB |
Output is correct |
71 |
Correct |
55 ms |
5368 KB |
Output is correct |
72 |
Correct |
47 ms |
5364 KB |
Output is correct |
73 |
Correct |
9 ms |
3504 KB |
Output is correct |
74 |
Correct |
27 ms |
4760 KB |
Output is correct |
75 |
Correct |
48 ms |
5368 KB |
Output is correct |
76 |
Correct |
20 ms |
4344 KB |
Output is correct |
77 |
Correct |
146 ms |
6008 KB |
Output is correct |
78 |
Correct |
9 ms |
3448 KB |
Output is correct |
79 |
Correct |
71 ms |
4344 KB |
Output is correct |
80 |
Correct |
21 ms |
4344 KB |
Output is correct |
81 |
Correct |
149 ms |
5948 KB |
Output is correct |
82 |
Correct |
8 ms |
2936 KB |
Output is correct |
83 |
Correct |
75 ms |
4348 KB |
Output is correct |
84 |
Correct |
60 ms |
5308 KB |
Output is correct |
85 |
Correct |
8 ms |
3080 KB |
Output is correct |
86 |
Correct |
32 ms |
5240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2684 KB |
Output is correct |
2 |
Correct |
4 ms |
2680 KB |
Output is correct |
3 |
Correct |
10 ms |
3448 KB |
Output is correct |
4 |
Correct |
10 ms |
3448 KB |
Output is correct |
5 |
Correct |
10 ms |
3448 KB |
Output is correct |
6 |
Correct |
10 ms |
3448 KB |
Output is correct |
7 |
Correct |
10 ms |
3420 KB |
Output is correct |
8 |
Correct |
9 ms |
2936 KB |
Output is correct |
9 |
Correct |
4 ms |
2680 KB |
Output is correct |
10 |
Correct |
5 ms |
2936 KB |
Output is correct |
11 |
Correct |
10 ms |
3448 KB |
Output is correct |
12 |
Correct |
11 ms |
3448 KB |
Output is correct |
13 |
Correct |
4 ms |
2680 KB |
Output is correct |
14 |
Correct |
12 ms |
3424 KB |
Output is correct |
15 |
Correct |
5 ms |
2808 KB |
Output is correct |
16 |
Correct |
10 ms |
3448 KB |
Output is correct |
17 |
Correct |
5 ms |
2680 KB |
Output is correct |
18 |
Correct |
10 ms |
3448 KB |
Output is correct |
19 |
Correct |
6 ms |
2936 KB |
Output is correct |
20 |
Correct |
9 ms |
3192 KB |
Output is correct |
21 |
Correct |
8 ms |
3196 KB |
Output is correct |
22 |
Correct |
7 ms |
2936 KB |
Output is correct |
23 |
Correct |
12 ms |
3704 KB |
Output is correct |
24 |
Correct |
5 ms |
2936 KB |
Output is correct |
25 |
Correct |
11 ms |
3576 KB |
Output is correct |
26 |
Correct |
11 ms |
3576 KB |
Output is correct |
27 |
Correct |
9 ms |
3448 KB |
Output is correct |
28 |
Correct |
11 ms |
3576 KB |
Output is correct |
29 |
Correct |
9 ms |
3448 KB |
Output is correct |
30 |
Correct |
15 ms |
3704 KB |
Output is correct |
31 |
Correct |
12 ms |
3704 KB |
Output is correct |
32 |
Correct |
12 ms |
3580 KB |
Output is correct |
33 |
Correct |
11 ms |
3704 KB |
Output is correct |
34 |
Correct |
12 ms |
3704 KB |
Output is correct |
35 |
Correct |
8 ms |
3192 KB |
Output is correct |
36 |
Correct |
8 ms |
3196 KB |
Output is correct |
37 |
Correct |
8 ms |
3192 KB |
Output is correct |
38 |
Correct |
7 ms |
3064 KB |
Output is correct |
39 |
Correct |
7 ms |
2936 KB |
Output is correct |
40 |
Correct |
16 ms |
3960 KB |
Output is correct |
41 |
Correct |
7 ms |
2936 KB |
Output is correct |
42 |
Correct |
16 ms |
3960 KB |
Output is correct |
43 |
Correct |
16 ms |
3960 KB |
Output is correct |
44 |
Correct |
4 ms |
2680 KB |
Output is correct |
45 |
Correct |
296 ms |
21012 KB |
Output is correct |
46 |
Correct |
117 ms |
13176 KB |
Output is correct |
47 |
Correct |
301 ms |
21040 KB |
Output is correct |
48 |
Correct |
300 ms |
21112 KB |
Output is correct |
49 |
Correct |
80 ms |
10364 KB |
Output is correct |
50 |
Correct |
372 ms |
26236 KB |
Output is correct |
51 |
Correct |
311 ms |
20992 KB |
Output is correct |
52 |
Correct |
77 ms |
10388 KB |
Output is correct |
53 |
Correct |
80 ms |
10488 KB |
Output is correct |
54 |
Correct |
20 ms |
5112 KB |
Output is correct |
55 |
Correct |
374 ms |
26224 KB |
Output is correct |
56 |
Correct |
46 ms |
7800 KB |
Output is correct |
57 |
Correct |
77 ms |
10360 KB |
Output is correct |
58 |
Correct |
92 ms |
13092 KB |
Output is correct |
59 |
Correct |
48 ms |
7800 KB |
Output is correct |
60 |
Correct |
49 ms |
7804 KB |
Output is correct |
61 |
Correct |
92 ms |
13048 KB |
Output is correct |
62 |
Correct |
71 ms |
10488 KB |
Output is correct |
63 |
Correct |
154 ms |
14436 KB |
Output is correct |
64 |
Correct |
46 ms |
7800 KB |
Output is correct |
65 |
Correct |
201 ms |
17016 KB |
Output is correct |
66 |
Correct |
69 ms |
10360 KB |
Output is correct |
67 |
Correct |
152 ms |
14428 KB |
Output is correct |
68 |
Correct |
189 ms |
16504 KB |
Output is correct |
69 |
Correct |
200 ms |
17272 KB |
Output is correct |
70 |
Correct |
78 ms |
10488 KB |
Output is correct |
71 |
Correct |
204 ms |
16376 KB |
Output is correct |
72 |
Correct |
140 ms |
13944 KB |
Output is correct |
73 |
Correct |
252 ms |
18808 KB |
Output is correct |
74 |
Correct |
78 ms |
10568 KB |
Output is correct |
75 |
Correct |
83 ms |
9084 KB |
Output is correct |
76 |
Correct |
144 ms |
13944 KB |
Output is correct |
77 |
Correct |
262 ms |
18756 KB |
Output is correct |
78 |
Correct |
147 ms |
10748 KB |
Output is correct |
79 |
Correct |
78 ms |
9080 KB |
Output is correct |
80 |
Correct |
37 ms |
5880 KB |
Output is correct |
81 |
Correct |
109 ms |
10744 KB |
Output is correct |
82 |
Correct |
172 ms |
15788 KB |
Output is correct |
83 |
Correct |
37 ms |
5880 KB |
Output is correct |
84 |
Correct |
172 ms |
15864 KB |
Output is correct |