#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using arr = array<int, 2>;
constexpr int maxn = 5e4, maxk = 11;
bool visited[maxn] = { 0 };
set<int> adj[maxn];
int k;
int output = 1;
void dfs(int pos)
{
assert(!visited[pos]);
// assert(adj[pos].size() <= k);
// cout << pos << endl;
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])
{
auto it = adj[pos].begin();
auto ft = adj[i].begin();
iii = 0;
v[ii][ii] = true;
while (it != adj[pos].end() && ft != adj[i].end())
{
if (*it < *ft)
{
it++;
iii++;
continue;
}
if (*ft < *it)
{
ft++;
continue;
}
v[ii][iii] = true;
it++, ft++;
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);
for (int i : adj[pos]) if ((int)adj[i].size() <= k && !visited[i]) dfs(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";
}
/*
Det er en ganske spesiell graf og derfor kan
*/
# |
결과 |
실행 시간 |
메모리 |
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 |
9 ms |
3028 KB |
Output is correct |
5 |
Correct |
12 ms |
3148 KB |
Output is correct |
6 |
Correct |
4 ms |
3028 KB |
Output is correct |
7 |
Correct |
4 ms |
3028 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
1 ms |
2644 KB |
Output is correct |
10 |
Correct |
2 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 |
9 ms |
3028 KB |
Output is correct |
5 |
Correct |
12 ms |
3148 KB |
Output is correct |
6 |
Correct |
4 ms |
3028 KB |
Output is correct |
7 |
Correct |
4 ms |
3028 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
1 ms |
2644 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
11 |
Correct |
7 ms |
3028 KB |
Output is correct |
12 |
Correct |
9 ms |
3028 KB |
Output is correct |
13 |
Correct |
1 ms |
2644 KB |
Output is correct |
14 |
Correct |
28 ms |
3140 KB |
Output is correct |
15 |
Correct |
1 ms |
2644 KB |
Output is correct |
16 |
Correct |
4 ms |
3028 KB |
Output is correct |
17 |
Correct |
1 ms |
2644 KB |
Output is correct |
18 |
Correct |
4 ms |
3028 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 |
1 ms |
2644 KB |
Output is correct |
23 |
Correct |
4 ms |
3540 KB |
Output is correct |
24 |
Correct |
2 ms |
2644 KB |
Output is correct |
25 |
Correct |
4 ms |
3540 KB |
Output is correct |
26 |
Correct |
4 ms |
3412 KB |
Output is correct |
27 |
Correct |
4 ms |
3924 KB |
Output is correct |
28 |
Correct |
4 ms |
3524 KB |
Output is correct |
29 |
Correct |
3 ms |
3924 KB |
Output is correct |
30 |
Correct |
11 ms |
3328 KB |
Output is correct |
31 |
Correct |
5 ms |
3668 KB |
Output is correct |
32 |
Correct |
9 ms |
3292 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 |
3200 KB |
Output is correct |
36 |
Correct |
3 ms |
3200 KB |
Output is correct |
37 |
Correct |
4 ms |
3156 KB |
Output is correct |
38 |
Correct |
2 ms |
2900 KB |
Output is correct |
39 |
Correct |
2 ms |
2924 KB |
Output is correct |
40 |
Correct |
6 ms |
3872 KB |
Output is correct |
41 |
Correct |
3 ms |
2900 KB |
Output is correct |
42 |
Correct |
6 ms |
3876 KB |
Output is correct |
43 |
Correct |
6 ms |
3924 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 |
1 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 |
240 ms |
29988 KB |
Output is correct |
12 |
Correct |
1 ms |
2644 KB |
Output is correct |
13 |
Correct |
227 ms |
32592 KB |
Output is correct |
14 |
Correct |
1 ms |
2644 KB |
Output is correct |
15 |
Correct |
226 ms |
32600 KB |
Output is correct |
16 |
Correct |
235 ms |
32744 KB |
Output is correct |
17 |
Correct |
229 ms |
32668 KB |
Output is correct |
18 |
Correct |
246 ms |
32612 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 |
9 ms |
3028 KB |
Output is correct |
5 |
Correct |
12 ms |
3148 KB |
Output is correct |
6 |
Correct |
4 ms |
3028 KB |
Output is correct |
7 |
Correct |
4 ms |
3028 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
1 ms |
2644 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
11 |
Correct |
7 ms |
3028 KB |
Output is correct |
12 |
Correct |
9 ms |
3028 KB |
Output is correct |
13 |
Correct |
1 ms |
2644 KB |
Output is correct |
14 |
Correct |
28 ms |
3140 KB |
Output is correct |
15 |
Correct |
1 ms |
2644 KB |
Output is correct |
16 |
Correct |
4 ms |
3028 KB |
Output is correct |
17 |
Correct |
1 ms |
2644 KB |
Output is correct |
18 |
Correct |
4 ms |
3028 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 |
1 ms |
2644 KB |
Output is correct |
23 |
Correct |
4 ms |
3540 KB |
Output is correct |
24 |
Correct |
2 ms |
2644 KB |
Output is correct |
25 |
Correct |
4 ms |
3540 KB |
Output is correct |
26 |
Correct |
4 ms |
3412 KB |
Output is correct |
27 |
Correct |
4 ms |
3924 KB |
Output is correct |
28 |
Correct |
4 ms |
3524 KB |
Output is correct |
29 |
Correct |
3 ms |
3924 KB |
Output is correct |
30 |
Correct |
11 ms |
3328 KB |
Output is correct |
31 |
Correct |
5 ms |
3668 KB |
Output is correct |
32 |
Correct |
9 ms |
3292 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 |
3200 KB |
Output is correct |
36 |
Correct |
3 ms |
3200 KB |
Output is correct |
37 |
Correct |
4 ms |
3156 KB |
Output is correct |
38 |
Correct |
2 ms |
2900 KB |
Output is correct |
39 |
Correct |
2 ms |
2924 KB |
Output is correct |
40 |
Correct |
6 ms |
3872 KB |
Output is correct |
41 |
Correct |
3 ms |
2900 KB |
Output is correct |
42 |
Correct |
6 ms |
3876 KB |
Output is correct |
43 |
Correct |
6 ms |
3924 KB |
Output is correct |
44 |
Correct |
13 ms |
4760 KB |
Output is correct |
45 |
Correct |
2 ms |
2772 KB |
Output is correct |
46 |
Correct |
6 ms |
4052 KB |
Output is correct |
47 |
Correct |
14 ms |
5332 KB |
Output is correct |
48 |
Correct |
6 ms |
4052 KB |
Output is correct |
49 |
Correct |
14 ms |
5332 KB |
Output is correct |
50 |
Correct |
18 ms |
5332 KB |
Output is correct |
51 |
Correct |
80 ms |
7332 KB |
Output is correct |
52 |
Correct |
4 ms |
3156 KB |
Output is correct |
53 |
Correct |
1163 ms |
7312 KB |
Output is correct |
54 |
Correct |
209 ms |
7884 KB |
Output is correct |
55 |
Correct |
7 ms |
3156 KB |
Output is correct |
56 |
Correct |
3 ms |
3156 KB |
Output is correct |
57 |
Correct |
2 ms |
2772 KB |
Output is correct |
58 |
Correct |
914 ms |
7364 KB |
Output is correct |
59 |
Correct |
5 ms |
3668 KB |
Output is correct |
60 |
Correct |
7 ms |
3208 KB |
Output is correct |
61 |
Correct |
5 ms |
3616 KB |
Output is correct |
62 |
Correct |
5 ms |
3668 KB |
Output is correct |
63 |
Correct |
13 ms |
4692 KB |
Output is correct |
64 |
Correct |
10 ms |
4436 KB |
Output is correct |
65 |
Correct |
5 ms |
3924 KB |
Output is correct |
66 |
Correct |
5 ms |
3668 KB |
Output is correct |
67 |
Correct |
69 ms |
5740 KB |
Output is correct |
68 |
Correct |
10 ms |
4436 KB |
Output is correct |
69 |
Correct |
5 ms |
3960 KB |
Output is correct |
70 |
Correct |
19 ms |
5112 KB |
Output is correct |
71 |
Correct |
66 ms |
5792 KB |
Output is correct |
72 |
Correct |
62 ms |
5628 KB |
Output is correct |
73 |
Correct |
3 ms |
3924 KB |
Output is correct |
74 |
Correct |
17 ms |
5068 KB |
Output is correct |
75 |
Correct |
64 ms |
5544 KB |
Output is correct |
76 |
Correct |
22 ms |
4500 KB |
Output is correct |
77 |
Correct |
83 ms |
6188 KB |
Output is correct |
78 |
Correct |
3 ms |
3836 KB |
Output is correct |
79 |
Correct |
41 ms |
4452 KB |
Output is correct |
80 |
Correct |
17 ms |
4488 KB |
Output is correct |
81 |
Correct |
83 ms |
6220 KB |
Output is correct |
82 |
Correct |
3 ms |
2816 KB |
Output is correct |
83 |
Correct |
43 ms |
4488 KB |
Output is correct |
84 |
Correct |
19 ms |
5604 KB |
Output is correct |
85 |
Correct |
3 ms |
2900 KB |
Output is correct |
86 |
Correct |
22 ms |
5560 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 |
9 ms |
3028 KB |
Output is correct |
5 |
Correct |
12 ms |
3148 KB |
Output is correct |
6 |
Correct |
4 ms |
3028 KB |
Output is correct |
7 |
Correct |
4 ms |
3028 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
1 ms |
2644 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
11 |
Correct |
7 ms |
3028 KB |
Output is correct |
12 |
Correct |
9 ms |
3028 KB |
Output is correct |
13 |
Correct |
1 ms |
2644 KB |
Output is correct |
14 |
Correct |
28 ms |
3140 KB |
Output is correct |
15 |
Correct |
1 ms |
2644 KB |
Output is correct |
16 |
Correct |
4 ms |
3028 KB |
Output is correct |
17 |
Correct |
1 ms |
2644 KB |
Output is correct |
18 |
Correct |
4 ms |
3028 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 |
1 ms |
2644 KB |
Output is correct |
23 |
Correct |
4 ms |
3540 KB |
Output is correct |
24 |
Correct |
2 ms |
2644 KB |
Output is correct |
25 |
Correct |
4 ms |
3540 KB |
Output is correct |
26 |
Correct |
4 ms |
3412 KB |
Output is correct |
27 |
Correct |
4 ms |
3924 KB |
Output is correct |
28 |
Correct |
4 ms |
3524 KB |
Output is correct |
29 |
Correct |
3 ms |
3924 KB |
Output is correct |
30 |
Correct |
11 ms |
3328 KB |
Output is correct |
31 |
Correct |
5 ms |
3668 KB |
Output is correct |
32 |
Correct |
9 ms |
3292 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 |
3200 KB |
Output is correct |
36 |
Correct |
3 ms |
3200 KB |
Output is correct |
37 |
Correct |
4 ms |
3156 KB |
Output is correct |
38 |
Correct |
2 ms |
2900 KB |
Output is correct |
39 |
Correct |
2 ms |
2924 KB |
Output is correct |
40 |
Correct |
6 ms |
3872 KB |
Output is correct |
41 |
Correct |
3 ms |
2900 KB |
Output is correct |
42 |
Correct |
6 ms |
3876 KB |
Output is correct |
43 |
Correct |
6 ms |
3924 KB |
Output is correct |
44 |
Correct |
1 ms |
2652 KB |
Output is correct |
45 |
Correct |
108 ms |
22220 KB |
Output is correct |
46 |
Correct |
441 ms |
10676 KB |
Output is correct |
47 |
Correct |
114 ms |
23500 KB |
Output is correct |
48 |
Correct |
103 ms |
22228 KB |
Output is correct |
49 |
Execution timed out |
3074 ms |
8032 KB |
Time limit exceeded |
50 |
Halted |
0 ms |
0 KB |
- |