#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using arr = array<int, 2>;
constexpr int maxn = 5e4 + 5, maxk = 11;
bool visited[maxn] = { 0 };
set<int> adj[maxn];
int k;
int output = 1;
void dfs(int pos)
{
// assert(!visited[pos]);
assert((int)adj[pos].size() <= k);
visited[pos] = true;
vector <bitset<maxk>> v(adj[pos].size());
int ii = 0; // Counts which place it is in the order of adj[pos]
int iii;
for (int i : adj[pos])
{
iii = 0;
v[ii][ii] = true;
for (int y : adj[pos])
{
if (i != y) {
v[ii][iii] = adj[i].count(y);
}
iii++;
}
ii++;
}
bitset<maxk> all;
for (int i = 1; i < (1 << (adj[pos].size())); i++){
all.set();
for (size_t y = 0; y < adj[pos].size(); y++) {
if (i & (1 << y)) all &= v[y];
}
// cout << i << " " << all << "\n";
if (__builtin_popcount(i) == all.count()) output = max(output, __builtin_popcount(i) + 1);
}
for (int i : adj[pos]) adj[i].erase(pos); // Something with the deletion is fishy, since
for (int i : adj[pos]) if (!visited[i] && (int)adj[i].size() <= k) dfs(i); // We need this !visited[i]
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n >> k;
for (int i = 0; i < n; i++)
{
int a, b;
cin >> a;
for (int y = 0; y < a; y++)
{
cin >> b;
adj[i].insert(b);
}
}
for (int i = 0; i < n; i++) if (!visited[i] && (int)adj[i].size() <= k) dfs(i);
cout << output << "\n";
// cerr << clock() / static_cast<double>(CLOCKS_PER_SEC) << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
3 ms |
3028 KB |
Output is correct |
4 |
Correct |
3 ms |
3028 KB |
Output is correct |
5 |
Correct |
5 ms |
3072 KB |
Output is correct |
6 |
Correct |
3 ms |
3028 KB |
Output is correct |
7 |
Correct |
3 ms |
3028 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
2 ms |
2644 KB |
Output is correct |
10 |
Correct |
1 ms |
2644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
3 ms |
3028 KB |
Output is correct |
4 |
Correct |
3 ms |
3028 KB |
Output is correct |
5 |
Correct |
5 ms |
3072 KB |
Output is correct |
6 |
Correct |
3 ms |
3028 KB |
Output is correct |
7 |
Correct |
3 ms |
3028 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
2 ms |
2644 KB |
Output is correct |
10 |
Correct |
1 ms |
2644 KB |
Output is correct |
11 |
Correct |
3 ms |
3028 KB |
Output is correct |
12 |
Correct |
3 ms |
3028 KB |
Output is correct |
13 |
Correct |
1 ms |
2644 KB |
Output is correct |
14 |
Correct |
3 ms |
3148 KB |
Output is correct |
15 |
Correct |
1 ms |
2644 KB |
Output is correct |
16 |
Correct |
3 ms |
3028 KB |
Output is correct |
17 |
Correct |
1 ms |
2644 KB |
Output is correct |
18 |
Correct |
3 ms |
3144 KB |
Output is correct |
19 |
Correct |
1 ms |
2644 KB |
Output is correct |
20 |
Correct |
2 ms |
2900 KB |
Output is correct |
21 |
Correct |
2 ms |
2900 KB |
Output is correct |
22 |
Correct |
2 ms |
2680 KB |
Output is correct |
23 |
Correct |
4 ms |
3540 KB |
Output is correct |
24 |
Correct |
1 ms |
2644 KB |
Output is correct |
25 |
Correct |
4 ms |
3528 KB |
Output is correct |
26 |
Correct |
5 ms |
3412 KB |
Output is correct |
27 |
Correct |
3 ms |
3796 KB |
Output is correct |
28 |
Correct |
4 ms |
3412 KB |
Output is correct |
29 |
Correct |
3 ms |
3796 KB |
Output is correct |
30 |
Correct |
4 ms |
3284 KB |
Output is correct |
31 |
Correct |
4 ms |
3668 KB |
Output is correct |
32 |
Correct |
4 ms |
3284 KB |
Output is correct |
33 |
Correct |
4 ms |
3668 KB |
Output is correct |
34 |
Correct |
4 ms |
3668 KB |
Output is correct |
35 |
Correct |
3 ms |
3156 KB |
Output is correct |
36 |
Correct |
3 ms |
3156 KB |
Output is correct |
37 |
Correct |
2 ms |
3156 KB |
Output is correct |
38 |
Correct |
2 ms |
2772 KB |
Output is correct |
39 |
Correct |
2 ms |
2900 KB |
Output is correct |
40 |
Correct |
5 ms |
3796 KB |
Output is correct |
41 |
Correct |
2 ms |
2900 KB |
Output is correct |
42 |
Correct |
6 ms |
3760 KB |
Output is correct |
43 |
Correct |
5 ms |
3796 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Correct |
1 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
1 ms |
2644 KB |
Output is correct |
7 |
Correct |
1 ms |
2644 KB |
Output is correct |
8 |
Correct |
1 ms |
2644 KB |
Output is correct |
9 |
Correct |
1 ms |
2644 KB |
Output is correct |
10 |
Correct |
1 ms |
2644 KB |
Output is correct |
11 |
Correct |
210 ms |
30080 KB |
Output is correct |
12 |
Correct |
1 ms |
2644 KB |
Output is correct |
13 |
Correct |
213 ms |
30068 KB |
Output is correct |
14 |
Correct |
1 ms |
2644 KB |
Output is correct |
15 |
Correct |
211 ms |
30036 KB |
Output is correct |
16 |
Correct |
201 ms |
30032 KB |
Output is correct |
17 |
Correct |
210 ms |
30084 KB |
Output is correct |
18 |
Correct |
257 ms |
30072 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
3 ms |
3028 KB |
Output is correct |
4 |
Correct |
3 ms |
3028 KB |
Output is correct |
5 |
Correct |
5 ms |
3072 KB |
Output is correct |
6 |
Correct |
3 ms |
3028 KB |
Output is correct |
7 |
Correct |
3 ms |
3028 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
2 ms |
2644 KB |
Output is correct |
10 |
Correct |
1 ms |
2644 KB |
Output is correct |
11 |
Correct |
3 ms |
3028 KB |
Output is correct |
12 |
Correct |
3 ms |
3028 KB |
Output is correct |
13 |
Correct |
1 ms |
2644 KB |
Output is correct |
14 |
Correct |
3 ms |
3148 KB |
Output is correct |
15 |
Correct |
1 ms |
2644 KB |
Output is correct |
16 |
Correct |
3 ms |
3028 KB |
Output is correct |
17 |
Correct |
1 ms |
2644 KB |
Output is correct |
18 |
Correct |
3 ms |
3144 KB |
Output is correct |
19 |
Correct |
1 ms |
2644 KB |
Output is correct |
20 |
Correct |
2 ms |
2900 KB |
Output is correct |
21 |
Correct |
2 ms |
2900 KB |
Output is correct |
22 |
Correct |
2 ms |
2680 KB |
Output is correct |
23 |
Correct |
4 ms |
3540 KB |
Output is correct |
24 |
Correct |
1 ms |
2644 KB |
Output is correct |
25 |
Correct |
4 ms |
3528 KB |
Output is correct |
26 |
Correct |
5 ms |
3412 KB |
Output is correct |
27 |
Correct |
3 ms |
3796 KB |
Output is correct |
28 |
Correct |
4 ms |
3412 KB |
Output is correct |
29 |
Correct |
3 ms |
3796 KB |
Output is correct |
30 |
Correct |
4 ms |
3284 KB |
Output is correct |
31 |
Correct |
4 ms |
3668 KB |
Output is correct |
32 |
Correct |
4 ms |
3284 KB |
Output is correct |
33 |
Correct |
4 ms |
3668 KB |
Output is correct |
34 |
Correct |
4 ms |
3668 KB |
Output is correct |
35 |
Correct |
3 ms |
3156 KB |
Output is correct |
36 |
Correct |
3 ms |
3156 KB |
Output is correct |
37 |
Correct |
2 ms |
3156 KB |
Output is correct |
38 |
Correct |
2 ms |
2772 KB |
Output is correct |
39 |
Correct |
2 ms |
2900 KB |
Output is correct |
40 |
Correct |
5 ms |
3796 KB |
Output is correct |
41 |
Correct |
2 ms |
2900 KB |
Output is correct |
42 |
Correct |
6 ms |
3760 KB |
Output is correct |
43 |
Correct |
5 ms |
3796 KB |
Output is correct |
44 |
Correct |
13 ms |
4436 KB |
Output is correct |
45 |
Correct |
1 ms |
2644 KB |
Output is correct |
46 |
Correct |
6 ms |
3924 KB |
Output is correct |
47 |
Correct |
13 ms |
5068 KB |
Output is correct |
48 |
Correct |
6 ms |
3924 KB |
Output is correct |
49 |
Correct |
14 ms |
5184 KB |
Output is correct |
50 |
Correct |
17 ms |
5072 KB |
Output is correct |
51 |
Correct |
75 ms |
6912 KB |
Output is correct |
52 |
Correct |
3 ms |
3028 KB |
Output is correct |
53 |
Correct |
84 ms |
6876 KB |
Output is correct |
54 |
Correct |
195 ms |
7472 KB |
Output is correct |
55 |
Correct |
7 ms |
3152 KB |
Output is correct |
56 |
Correct |
3 ms |
3156 KB |
Output is correct |
57 |
Correct |
2 ms |
2644 KB |
Output is correct |
58 |
Correct |
71 ms |
6880 KB |
Output is correct |
59 |
Correct |
5 ms |
3540 KB |
Output is correct |
60 |
Correct |
6 ms |
3028 KB |
Output is correct |
61 |
Correct |
5 ms |
3540 KB |
Output is correct |
62 |
Correct |
5 ms |
3540 KB |
Output is correct |
63 |
Correct |
13 ms |
4436 KB |
Output is correct |
64 |
Correct |
11 ms |
4436 KB |
Output is correct |
65 |
Correct |
5 ms |
3924 KB |
Output is correct |
66 |
Correct |
5 ms |
3540 KB |
Output is correct |
67 |
Correct |
66 ms |
5516 KB |
Output is correct |
68 |
Correct |
9 ms |
4308 KB |
Output is correct |
69 |
Correct |
5 ms |
3924 KB |
Output is correct |
70 |
Correct |
14 ms |
4968 KB |
Output is correct |
71 |
Correct |
63 ms |
5552 KB |
Output is correct |
72 |
Correct |
60 ms |
5340 KB |
Output is correct |
73 |
Correct |
3 ms |
3796 KB |
Output is correct |
74 |
Correct |
16 ms |
4948 KB |
Output is correct |
75 |
Correct |
62 ms |
5324 KB |
Output is correct |
76 |
Correct |
8 ms |
4308 KB |
Output is correct |
77 |
Correct |
79 ms |
6092 KB |
Output is correct |
78 |
Correct |
3 ms |
3796 KB |
Output is correct |
79 |
Correct |
39 ms |
4264 KB |
Output is correct |
80 |
Correct |
8 ms |
4308 KB |
Output is correct |
81 |
Correct |
79 ms |
5988 KB |
Output is correct |
82 |
Correct |
2 ms |
2900 KB |
Output is correct |
83 |
Correct |
44 ms |
4296 KB |
Output is correct |
84 |
Correct |
18 ms |
5424 KB |
Output is correct |
85 |
Correct |
2 ms |
2900 KB |
Output is correct |
86 |
Correct |
18 ms |
5460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
3 ms |
3028 KB |
Output is correct |
4 |
Correct |
3 ms |
3028 KB |
Output is correct |
5 |
Correct |
5 ms |
3072 KB |
Output is correct |
6 |
Correct |
3 ms |
3028 KB |
Output is correct |
7 |
Correct |
3 ms |
3028 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
2 ms |
2644 KB |
Output is correct |
10 |
Correct |
1 ms |
2644 KB |
Output is correct |
11 |
Correct |
3 ms |
3028 KB |
Output is correct |
12 |
Correct |
3 ms |
3028 KB |
Output is correct |
13 |
Correct |
1 ms |
2644 KB |
Output is correct |
14 |
Correct |
3 ms |
3148 KB |
Output is correct |
15 |
Correct |
1 ms |
2644 KB |
Output is correct |
16 |
Correct |
3 ms |
3028 KB |
Output is correct |
17 |
Correct |
1 ms |
2644 KB |
Output is correct |
18 |
Correct |
3 ms |
3144 KB |
Output is correct |
19 |
Correct |
1 ms |
2644 KB |
Output is correct |
20 |
Correct |
2 ms |
2900 KB |
Output is correct |
21 |
Correct |
2 ms |
2900 KB |
Output is correct |
22 |
Correct |
2 ms |
2680 KB |
Output is correct |
23 |
Correct |
4 ms |
3540 KB |
Output is correct |
24 |
Correct |
1 ms |
2644 KB |
Output is correct |
25 |
Correct |
4 ms |
3528 KB |
Output is correct |
26 |
Correct |
5 ms |
3412 KB |
Output is correct |
27 |
Correct |
3 ms |
3796 KB |
Output is correct |
28 |
Correct |
4 ms |
3412 KB |
Output is correct |
29 |
Correct |
3 ms |
3796 KB |
Output is correct |
30 |
Correct |
4 ms |
3284 KB |
Output is correct |
31 |
Correct |
4 ms |
3668 KB |
Output is correct |
32 |
Correct |
4 ms |
3284 KB |
Output is correct |
33 |
Correct |
4 ms |
3668 KB |
Output is correct |
34 |
Correct |
4 ms |
3668 KB |
Output is correct |
35 |
Correct |
3 ms |
3156 KB |
Output is correct |
36 |
Correct |
3 ms |
3156 KB |
Output is correct |
37 |
Correct |
2 ms |
3156 KB |
Output is correct |
38 |
Correct |
2 ms |
2772 KB |
Output is correct |
39 |
Correct |
2 ms |
2900 KB |
Output is correct |
40 |
Correct |
5 ms |
3796 KB |
Output is correct |
41 |
Correct |
2 ms |
2900 KB |
Output is correct |
42 |
Correct |
6 ms |
3760 KB |
Output is correct |
43 |
Correct |
5 ms |
3796 KB |
Output is correct |
44 |
Correct |
1 ms |
2644 KB |
Output is correct |
45 |
Correct |
91 ms |
20404 KB |
Output is correct |
46 |
Correct |
34 ms |
9648 KB |
Output is correct |
47 |
Correct |
92 ms |
21732 KB |
Output is correct |
48 |
Correct |
92 ms |
20424 KB |
Output is correct |
49 |
Correct |
23 ms |
7348 KB |
Output is correct |
50 |
Correct |
105 ms |
23808 KB |
Output is correct |
51 |
Correct |
100 ms |
23500 KB |
Output is correct |
52 |
Correct |
21 ms |
8020 KB |
Output is correct |
53 |
Correct |
30 ms |
8056 KB |
Output is correct |
54 |
Correct |
4 ms |
2772 KB |
Output is correct |
55 |
Correct |
111 ms |
23820 KB |
Output is correct |
56 |
Correct |
10 ms |
5332 KB |
Output is correct |
57 |
Correct |
22 ms |
8012 KB |
Output is correct |
58 |
Correct |
28 ms |
10572 KB |
Output is correct |
59 |
Correct |
11 ms |
5332 KB |
Output is correct |
60 |
Correct |
10 ms |
5332 KB |
Output is correct |
61 |
Correct |
26 ms |
10572 KB |
Output is correct |
62 |
Correct |
20 ms |
8104 KB |
Output is correct |
63 |
Correct |
48 ms |
16068 KB |
Output is correct |
64 |
Correct |
10 ms |
5332 KB |
Output is correct |
65 |
Correct |
64 ms |
19172 KB |
Output is correct |
66 |
Correct |
24 ms |
8020 KB |
Output is correct |
67 |
Correct |
46 ms |
15948 KB |
Output is correct |
68 |
Correct |
59 ms |
18424 KB |
Output is correct |
69 |
Correct |
64 ms |
19252 KB |
Output is correct |
70 |
Correct |
27 ms |
15016 KB |
Output is correct |
71 |
Correct |
65 ms |
18480 KB |
Output is correct |
72 |
Correct |
51 ms |
14020 KB |
Output is correct |
73 |
Correct |
84 ms |
21708 KB |
Output is correct |
74 |
Correct |
26 ms |
15020 KB |
Output is correct |
75 |
Correct |
24 ms |
10292 KB |
Output is correct |
76 |
Correct |
46 ms |
13900 KB |
Output is correct |
77 |
Correct |
81 ms |
21696 KB |
Output is correct |
78 |
Correct |
45 ms |
12288 KB |
Output is correct |
79 |
Correct |
30 ms |
10356 KB |
Output is correct |
80 |
Correct |
12 ms |
5204 KB |
Output is correct |
81 |
Correct |
33 ms |
12156 KB |
Output is correct |
82 |
Correct |
49 ms |
18532 KB |
Output is correct |
83 |
Correct |
12 ms |
5180 KB |
Output is correct |
84 |
Correct |
50 ms |
18600 KB |
Output is correct |