#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
int main(const int argc, const char *argv[]) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, k;
cin >> n >> k;
vector <set <int>> adj(n);
set <pii> S;
for(int i = 0; i < n; ++i) {
int d;
cin >> d;
for(int j = 0; j < d; ++j) {
int x;
cin >> x;
adj[i].insert(x);
}
S.insert({d, i});
}
int ans = 1;
while (!S.empty()) {
int u = (*S.begin()).second;
S.erase(S.begin());
vector <int> node;
node.push_back(u);
for(int x : adj[u]) {
node.push_back(x);
}
int d = node.size();
for(int i = 1; i < 1<<d; ++i) {
vector <int> tmp;
for(int j = 0; j < d; ++j) {
if (i&(1<<j)) tmp.push_back(node[j]);
}
bool flag = true;
int size = tmp.size();
for(int j = 0; flag && j < size; ++j) {
for(int k = j+1; flag && k < size; ++k) {
if (adj[tmp[j]].find(tmp[k]) == adj[tmp[j]].end()) flag = false;
}
}
if (flag) ans = max(ans, size);
}
for(int i = 1; i < d; ++i) {
int x = node[i];
S.erase({adj[x].size(), x});
adj[x].erase(u);
S.insert({adj[x].size(), x});
}
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
17 ms |
1236 KB |
Output is correct |
4 |
Correct |
9 ms |
1236 KB |
Output is correct |
5 |
Correct |
5 ms |
1224 KB |
Output is correct |
6 |
Correct |
6 ms |
1236 KB |
Output is correct |
7 |
Correct |
9 ms |
1236 KB |
Output is correct |
8 |
Correct |
3 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
17 ms |
1236 KB |
Output is correct |
4 |
Correct |
9 ms |
1236 KB |
Output is correct |
5 |
Correct |
5 ms |
1224 KB |
Output is correct |
6 |
Correct |
6 ms |
1236 KB |
Output is correct |
7 |
Correct |
9 ms |
1236 KB |
Output is correct |
8 |
Correct |
3 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
724 KB |
Output is correct |
11 |
Correct |
6 ms |
1236 KB |
Output is correct |
12 |
Correct |
6 ms |
1244 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
7 ms |
1220 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
7 ms |
1236 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
8 ms |
1236 KB |
Output is correct |
19 |
Correct |
2 ms |
724 KB |
Output is correct |
20 |
Correct |
3 ms |
980 KB |
Output is correct |
21 |
Correct |
4 ms |
980 KB |
Output is correct |
22 |
Correct |
2 ms |
724 KB |
Output is correct |
23 |
Correct |
7 ms |
1364 KB |
Output is correct |
24 |
Correct |
2 ms |
708 KB |
Output is correct |
25 |
Correct |
7 ms |
1404 KB |
Output is correct |
26 |
Correct |
7 ms |
1364 KB |
Output is correct |
27 |
Correct |
5 ms |
1236 KB |
Output is correct |
28 |
Correct |
8 ms |
1364 KB |
Output is correct |
29 |
Correct |
5 ms |
1244 KB |
Output is correct |
30 |
Correct |
8 ms |
1380 KB |
Output is correct |
31 |
Correct |
8 ms |
1492 KB |
Output is correct |
32 |
Correct |
9 ms |
1492 KB |
Output is correct |
33 |
Correct |
8 ms |
1488 KB |
Output is correct |
34 |
Correct |
12 ms |
1364 KB |
Output is correct |
35 |
Correct |
4 ms |
852 KB |
Output is correct |
36 |
Correct |
4 ms |
836 KB |
Output is correct |
37 |
Correct |
4 ms |
884 KB |
Output is correct |
38 |
Correct |
3 ms |
596 KB |
Output is correct |
39 |
Correct |
3 ms |
584 KB |
Output is correct |
40 |
Correct |
16 ms |
1740 KB |
Output is correct |
41 |
Correct |
3 ms |
596 KB |
Output is correct |
42 |
Correct |
13 ms |
1748 KB |
Output is correct |
43 |
Correct |
18 ms |
1736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
724 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
316 KB |
Output is correct |
7 |
Correct |
1 ms |
320 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1006 ms |
28696 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
990 ms |
28688 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1044 ms |
28720 KB |
Output is correct |
16 |
Correct |
988 ms |
28724 KB |
Output is correct |
17 |
Correct |
976 ms |
28748 KB |
Output is correct |
18 |
Correct |
1059 ms |
28760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
17 ms |
1236 KB |
Output is correct |
4 |
Correct |
9 ms |
1236 KB |
Output is correct |
5 |
Correct |
5 ms |
1224 KB |
Output is correct |
6 |
Correct |
6 ms |
1236 KB |
Output is correct |
7 |
Correct |
9 ms |
1236 KB |
Output is correct |
8 |
Correct |
3 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
724 KB |
Output is correct |
11 |
Correct |
6 ms |
1236 KB |
Output is correct |
12 |
Correct |
6 ms |
1244 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
7 ms |
1220 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
7 ms |
1236 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
8 ms |
1236 KB |
Output is correct |
19 |
Correct |
2 ms |
724 KB |
Output is correct |
20 |
Correct |
3 ms |
980 KB |
Output is correct |
21 |
Correct |
4 ms |
980 KB |
Output is correct |
22 |
Correct |
2 ms |
724 KB |
Output is correct |
23 |
Correct |
7 ms |
1364 KB |
Output is correct |
24 |
Correct |
2 ms |
708 KB |
Output is correct |
25 |
Correct |
7 ms |
1404 KB |
Output is correct |
26 |
Correct |
7 ms |
1364 KB |
Output is correct |
27 |
Correct |
5 ms |
1236 KB |
Output is correct |
28 |
Correct |
8 ms |
1364 KB |
Output is correct |
29 |
Correct |
5 ms |
1244 KB |
Output is correct |
30 |
Correct |
8 ms |
1380 KB |
Output is correct |
31 |
Correct |
8 ms |
1492 KB |
Output is correct |
32 |
Correct |
9 ms |
1492 KB |
Output is correct |
33 |
Correct |
8 ms |
1488 KB |
Output is correct |
34 |
Correct |
12 ms |
1364 KB |
Output is correct |
35 |
Correct |
4 ms |
852 KB |
Output is correct |
36 |
Correct |
4 ms |
836 KB |
Output is correct |
37 |
Correct |
4 ms |
884 KB |
Output is correct |
38 |
Correct |
3 ms |
596 KB |
Output is correct |
39 |
Correct |
3 ms |
584 KB |
Output is correct |
40 |
Correct |
16 ms |
1740 KB |
Output is correct |
41 |
Correct |
3 ms |
596 KB |
Output is correct |
42 |
Correct |
13 ms |
1748 KB |
Output is correct |
43 |
Correct |
18 ms |
1736 KB |
Output is correct |
44 |
Correct |
144 ms |
2772 KB |
Output is correct |
45 |
Correct |
1 ms |
320 KB |
Output is correct |
46 |
Correct |
11 ms |
1800 KB |
Output is correct |
47 |
Correct |
42 ms |
2748 KB |
Output is correct |
48 |
Correct |
12 ms |
1748 KB |
Output is correct |
49 |
Correct |
41 ms |
2780 KB |
Output is correct |
50 |
Correct |
61 ms |
2816 KB |
Output is correct |
51 |
Correct |
535 ms |
4868 KB |
Output is correct |
52 |
Correct |
5 ms |
1236 KB |
Output is correct |
53 |
Correct |
1098 ms |
5432 KB |
Output is correct |
54 |
Correct |
1113 ms |
5344 KB |
Output is correct |
55 |
Correct |
6 ms |
1236 KB |
Output is correct |
56 |
Correct |
6 ms |
1224 KB |
Output is correct |
57 |
Correct |
2 ms |
724 KB |
Output is correct |
58 |
Correct |
1000 ms |
5348 KB |
Output is correct |
59 |
Correct |
13 ms |
1868 KB |
Output is correct |
60 |
Correct |
6 ms |
1236 KB |
Output is correct |
61 |
Correct |
13 ms |
1748 KB |
Output is correct |
62 |
Correct |
14 ms |
1748 KB |
Output is correct |
63 |
Correct |
141 ms |
2772 KB |
Output is correct |
64 |
Correct |
79 ms |
2516 KB |
Output is correct |
65 |
Correct |
10 ms |
1620 KB |
Output is correct |
66 |
Correct |
12 ms |
1748 KB |
Output is correct |
67 |
Correct |
106 ms |
3260 KB |
Output is correct |
68 |
Correct |
69 ms |
2516 KB |
Output is correct |
69 |
Correct |
10 ms |
1620 KB |
Output is correct |
70 |
Correct |
38 ms |
2644 KB |
Output is correct |
71 |
Correct |
128 ms |
3156 KB |
Output is correct |
72 |
Correct |
78 ms |
3156 KB |
Output is correct |
73 |
Correct |
5 ms |
1236 KB |
Output is correct |
74 |
Correct |
37 ms |
2632 KB |
Output is correct |
75 |
Correct |
86 ms |
3112 KB |
Output is correct |
76 |
Correct |
17 ms |
2132 KB |
Output is correct |
77 |
Correct |
209 ms |
3712 KB |
Output is correct |
78 |
Correct |
6 ms |
1240 KB |
Output is correct |
79 |
Correct |
94 ms |
2016 KB |
Output is correct |
80 |
Correct |
17 ms |
2132 KB |
Output is correct |
81 |
Correct |
188 ms |
3708 KB |
Output is correct |
82 |
Correct |
3 ms |
596 KB |
Output is correct |
83 |
Correct |
93 ms |
2016 KB |
Output is correct |
84 |
Correct |
89 ms |
3028 KB |
Output is correct |
85 |
Correct |
3 ms |
584 KB |
Output is correct |
86 |
Correct |
76 ms |
3028 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
17 ms |
1236 KB |
Output is correct |
4 |
Correct |
9 ms |
1236 KB |
Output is correct |
5 |
Correct |
5 ms |
1224 KB |
Output is correct |
6 |
Correct |
6 ms |
1236 KB |
Output is correct |
7 |
Correct |
9 ms |
1236 KB |
Output is correct |
8 |
Correct |
3 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
724 KB |
Output is correct |
11 |
Correct |
6 ms |
1236 KB |
Output is correct |
12 |
Correct |
6 ms |
1244 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
7 ms |
1220 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
7 ms |
1236 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
8 ms |
1236 KB |
Output is correct |
19 |
Correct |
2 ms |
724 KB |
Output is correct |
20 |
Correct |
3 ms |
980 KB |
Output is correct |
21 |
Correct |
4 ms |
980 KB |
Output is correct |
22 |
Correct |
2 ms |
724 KB |
Output is correct |
23 |
Correct |
7 ms |
1364 KB |
Output is correct |
24 |
Correct |
2 ms |
708 KB |
Output is correct |
25 |
Correct |
7 ms |
1404 KB |
Output is correct |
26 |
Correct |
7 ms |
1364 KB |
Output is correct |
27 |
Correct |
5 ms |
1236 KB |
Output is correct |
28 |
Correct |
8 ms |
1364 KB |
Output is correct |
29 |
Correct |
5 ms |
1244 KB |
Output is correct |
30 |
Correct |
8 ms |
1380 KB |
Output is correct |
31 |
Correct |
8 ms |
1492 KB |
Output is correct |
32 |
Correct |
9 ms |
1492 KB |
Output is correct |
33 |
Correct |
8 ms |
1488 KB |
Output is correct |
34 |
Correct |
12 ms |
1364 KB |
Output is correct |
35 |
Correct |
4 ms |
852 KB |
Output is correct |
36 |
Correct |
4 ms |
836 KB |
Output is correct |
37 |
Correct |
4 ms |
884 KB |
Output is correct |
38 |
Correct |
3 ms |
596 KB |
Output is correct |
39 |
Correct |
3 ms |
584 KB |
Output is correct |
40 |
Correct |
16 ms |
1740 KB |
Output is correct |
41 |
Correct |
3 ms |
596 KB |
Output is correct |
42 |
Correct |
13 ms |
1748 KB |
Output is correct |
43 |
Correct |
18 ms |
1736 KB |
Output is correct |
44 |
Correct |
1 ms |
212 KB |
Output is correct |
45 |
Correct |
289 ms |
20784 KB |
Output is correct |
46 |
Correct |
118 ms |
12896 KB |
Output is correct |
47 |
Correct |
322 ms |
20864 KB |
Output is correct |
48 |
Correct |
317 ms |
20884 KB |
Output is correct |
49 |
Correct |
81 ms |
10368 KB |
Output is correct |
50 |
Correct |
373 ms |
26116 KB |
Output is correct |
51 |
Correct |
397 ms |
20868 KB |
Output is correct |
52 |
Correct |
60 ms |
10328 KB |
Output is correct |
53 |
Correct |
61 ms |
10304 KB |
Output is correct |
54 |
Correct |
18 ms |
5060 KB |
Output is correct |
55 |
Correct |
388 ms |
26060 KB |
Output is correct |
56 |
Correct |
35 ms |
7628 KB |
Output is correct |
57 |
Correct |
58 ms |
10292 KB |
Output is correct |
58 |
Correct |
89 ms |
12900 KB |
Output is correct |
59 |
Correct |
39 ms |
7668 KB |
Output is correct |
60 |
Correct |
46 ms |
7628 KB |
Output is correct |
61 |
Correct |
103 ms |
12876 KB |
Output is correct |
62 |
Correct |
60 ms |
10260 KB |
Output is correct |
63 |
Correct |
130 ms |
14208 KB |
Output is correct |
64 |
Correct |
36 ms |
7624 KB |
Output is correct |
65 |
Correct |
229 ms |
16888 KB |
Output is correct |
66 |
Correct |
59 ms |
10348 KB |
Output is correct |
67 |
Correct |
136 ms |
14276 KB |
Output is correct |
68 |
Correct |
180 ms |
16220 KB |
Output is correct |
69 |
Correct |
195 ms |
16944 KB |
Output is correct |
70 |
Correct |
73 ms |
10264 KB |
Output is correct |
71 |
Correct |
212 ms |
16236 KB |
Output is correct |
72 |
Correct |
119 ms |
13804 KB |
Output is correct |
73 |
Correct |
226 ms |
18592 KB |
Output is correct |
74 |
Correct |
70 ms |
10316 KB |
Output is correct |
75 |
Correct |
90 ms |
7756 KB |
Output is correct |
76 |
Correct |
118 ms |
13788 KB |
Output is correct |
77 |
Correct |
224 ms |
18516 KB |
Output is correct |
78 |
Correct |
101 ms |
9368 KB |
Output is correct |
79 |
Correct |
87 ms |
7744 KB |
Output is correct |
80 |
Correct |
41 ms |
4060 KB |
Output is correct |
81 |
Correct |
97 ms |
9372 KB |
Output is correct |
82 |
Correct |
153 ms |
15620 KB |
Output is correct |
83 |
Correct |
30 ms |
4052 KB |
Output is correct |
84 |
Correct |
181 ms |
15524 KB |
Output is correct |