#include <iostream>
#include <vector>
#include <set>
#include <bitset>
#include <cassert>
#include <array>
#define int int64_t
#define bs bitset<10>
using namespace std;
struct findcliq
{
int n;
bitset<(1<<10)> b;
array<bitset<10>, 10> adjmat;
int find()
{
assert(n <= 10);
b[0] = 1;
int mmax = 0;
for (int i = 1; i < (1<<n); i++)
{
for (int ad = 0; ad < n; ad++)
{
if (!(i & (1<<ad))) continue;
int ls = i - (1<<ad);
if (!b[ls]) continue;
bool ok = true;
for (int in = 0; in < n; in++)
{
if ((1<<in) & ls)
{
if (!adjmat[in][ad]) ok = false;
}
}
b[i] = b[i] | ok;
}
if (b[i]) mmax = max(mmax, (int)__builtin_popcount(i));
}
return mmax;
}
void print()
{
cout << n << "\n";
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
cout << adjmat[i][j];
}
cout << "\n";
}
cout << "\n";
}
};
struct graph
{
int n;
vector<set<int>> adjset;
multiset<pair<int,int>> act;
int solve()
{
int res = 0;
for (int i = 0; i < n; i++)
{
act.insert({adjset[i].size(), i});
}
while (!act.empty())
{
int curr = act.begin()->second;
act.erase(act.begin());
int sz = adjset[curr].size() + 1;
findcliq fq;
fq.n = sz;
vector<int> all(adjset[curr].begin(), adjset[curr].end());
all.push_back(curr);
for (int i = 0; i < sz; i++)
{
for (int j = 0; j < sz; j++)
{
fq.adjmat[i][j] = adjset[all[i]].count(all[j]);
}
}
for (auto next : adjset[curr])
{
act.erase({adjset[next].size(), next});
adjset[next].erase(curr);
act.insert({adjset[next].size(), next});
}
res = max(res, fq.find());
}
return res;
}
};
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, k;
cin >> n >> k;
graph g;
g.n = n;
g.adjset.resize(n);
for (int i = 0; i < n; i++)
{
int cnt;
cin >> cnt;
for (int j = 0; j < cnt; j++)
{
int a;
cin >> a;
g.adjset[i].insert(a);
}
}
cout << g.solve() << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
11 ms |
1408 KB |
Output is correct |
4 |
Correct |
10 ms |
1408 KB |
Output is correct |
5 |
Correct |
11 ms |
1408 KB |
Output is correct |
6 |
Correct |
11 ms |
1408 KB |
Output is correct |
7 |
Correct |
11 ms |
1408 KB |
Output is correct |
8 |
Correct |
6 ms |
896 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
6 ms |
896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
11 ms |
1408 KB |
Output is correct |
4 |
Correct |
10 ms |
1408 KB |
Output is correct |
5 |
Correct |
11 ms |
1408 KB |
Output is correct |
6 |
Correct |
11 ms |
1408 KB |
Output is correct |
7 |
Correct |
11 ms |
1408 KB |
Output is correct |
8 |
Correct |
6 ms |
896 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
6 ms |
896 KB |
Output is correct |
11 |
Correct |
11 ms |
1408 KB |
Output is correct |
12 |
Correct |
13 ms |
1664 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
11 ms |
1408 KB |
Output is correct |
15 |
Correct |
4 ms |
384 KB |
Output is correct |
16 |
Correct |
11 ms |
1408 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
11 ms |
1408 KB |
Output is correct |
19 |
Correct |
7 ms |
896 KB |
Output is correct |
20 |
Correct |
10 ms |
1152 KB |
Output is correct |
21 |
Correct |
8 ms |
1152 KB |
Output is correct |
22 |
Correct |
6 ms |
896 KB |
Output is correct |
23 |
Correct |
12 ms |
1536 KB |
Output is correct |
24 |
Correct |
6 ms |
896 KB |
Output is correct |
25 |
Correct |
12 ms |
1536 KB |
Output is correct |
26 |
Correct |
11 ms |
1536 KB |
Output is correct |
27 |
Correct |
10 ms |
1408 KB |
Output is correct |
28 |
Correct |
12 ms |
1536 KB |
Output is correct |
29 |
Correct |
10 ms |
1408 KB |
Output is correct |
30 |
Correct |
13 ms |
1536 KB |
Output is correct |
31 |
Correct |
13 ms |
1536 KB |
Output is correct |
32 |
Correct |
13 ms |
1536 KB |
Output is correct |
33 |
Correct |
12 ms |
1664 KB |
Output is correct |
34 |
Correct |
14 ms |
1536 KB |
Output is correct |
35 |
Correct |
8 ms |
1024 KB |
Output is correct |
36 |
Correct |
8 ms |
896 KB |
Output is correct |
37 |
Correct |
8 ms |
896 KB |
Output is correct |
38 |
Correct |
7 ms |
768 KB |
Output is correct |
39 |
Correct |
7 ms |
768 KB |
Output is correct |
40 |
Correct |
16 ms |
1920 KB |
Output is correct |
41 |
Correct |
7 ms |
768 KB |
Output is correct |
42 |
Correct |
16 ms |
1920 KB |
Output is correct |
43 |
Correct |
17 ms |
1920 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
896 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
548 ms |
29560 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
486 ms |
29560 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
502 ms |
29560 KB |
Output is correct |
16 |
Correct |
519 ms |
29560 KB |
Output is correct |
17 |
Correct |
497 ms |
29560 KB |
Output is correct |
18 |
Correct |
500 ms |
29688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
11 ms |
1408 KB |
Output is correct |
4 |
Correct |
10 ms |
1408 KB |
Output is correct |
5 |
Correct |
11 ms |
1408 KB |
Output is correct |
6 |
Correct |
11 ms |
1408 KB |
Output is correct |
7 |
Correct |
11 ms |
1408 KB |
Output is correct |
8 |
Correct |
6 ms |
896 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
6 ms |
896 KB |
Output is correct |
11 |
Correct |
11 ms |
1408 KB |
Output is correct |
12 |
Correct |
13 ms |
1664 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
11 ms |
1408 KB |
Output is correct |
15 |
Correct |
4 ms |
384 KB |
Output is correct |
16 |
Correct |
11 ms |
1408 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
11 ms |
1408 KB |
Output is correct |
19 |
Correct |
7 ms |
896 KB |
Output is correct |
20 |
Correct |
10 ms |
1152 KB |
Output is correct |
21 |
Correct |
8 ms |
1152 KB |
Output is correct |
22 |
Correct |
6 ms |
896 KB |
Output is correct |
23 |
Correct |
12 ms |
1536 KB |
Output is correct |
24 |
Correct |
6 ms |
896 KB |
Output is correct |
25 |
Correct |
12 ms |
1536 KB |
Output is correct |
26 |
Correct |
11 ms |
1536 KB |
Output is correct |
27 |
Correct |
10 ms |
1408 KB |
Output is correct |
28 |
Correct |
12 ms |
1536 KB |
Output is correct |
29 |
Correct |
10 ms |
1408 KB |
Output is correct |
30 |
Correct |
13 ms |
1536 KB |
Output is correct |
31 |
Correct |
13 ms |
1536 KB |
Output is correct |
32 |
Correct |
13 ms |
1536 KB |
Output is correct |
33 |
Correct |
12 ms |
1664 KB |
Output is correct |
34 |
Correct |
14 ms |
1536 KB |
Output is correct |
35 |
Correct |
8 ms |
1024 KB |
Output is correct |
36 |
Correct |
8 ms |
896 KB |
Output is correct |
37 |
Correct |
8 ms |
896 KB |
Output is correct |
38 |
Correct |
7 ms |
768 KB |
Output is correct |
39 |
Correct |
7 ms |
768 KB |
Output is correct |
40 |
Correct |
16 ms |
1920 KB |
Output is correct |
41 |
Correct |
7 ms |
768 KB |
Output is correct |
42 |
Correct |
16 ms |
1920 KB |
Output is correct |
43 |
Correct |
17 ms |
1920 KB |
Output is correct |
44 |
Correct |
134 ms |
2944 KB |
Output is correct |
45 |
Correct |
5 ms |
384 KB |
Output is correct |
46 |
Correct |
17 ms |
1920 KB |
Output is correct |
47 |
Correct |
32 ms |
2944 KB |
Output is correct |
48 |
Correct |
17 ms |
1920 KB |
Output is correct |
49 |
Correct |
32 ms |
2944 KB |
Output is correct |
50 |
Correct |
33 ms |
2944 KB |
Output is correct |
51 |
Correct |
157 ms |
4984 KB |
Output is correct |
52 |
Correct |
10 ms |
1408 KB |
Output is correct |
53 |
Correct |
249 ms |
5504 KB |
Output is correct |
54 |
Correct |
273 ms |
5504 KB |
Output is correct |
55 |
Correct |
13 ms |
1408 KB |
Output is correct |
56 |
Correct |
11 ms |
1408 KB |
Output is correct |
57 |
Correct |
6 ms |
896 KB |
Output is correct |
58 |
Correct |
239 ms |
5496 KB |
Output is correct |
59 |
Correct |
15 ms |
1920 KB |
Output is correct |
60 |
Correct |
11 ms |
1408 KB |
Output is correct |
61 |
Correct |
15 ms |
1920 KB |
Output is correct |
62 |
Correct |
16 ms |
1920 KB |
Output is correct |
63 |
Correct |
133 ms |
2944 KB |
Output is correct |
64 |
Correct |
67 ms |
2688 KB |
Output is correct |
65 |
Correct |
15 ms |
1792 KB |
Output is correct |
66 |
Correct |
16 ms |
1920 KB |
Output is correct |
67 |
Correct |
74 ms |
3328 KB |
Output is correct |
68 |
Correct |
66 ms |
2688 KB |
Output is correct |
69 |
Correct |
15 ms |
1792 KB |
Output is correct |
70 |
Correct |
30 ms |
2816 KB |
Output is correct |
71 |
Correct |
77 ms |
3320 KB |
Output is correct |
72 |
Correct |
57 ms |
3280 KB |
Output is correct |
73 |
Correct |
10 ms |
1408 KB |
Output is correct |
74 |
Correct |
31 ms |
2816 KB |
Output is correct |
75 |
Correct |
55 ms |
3328 KB |
Output is correct |
76 |
Correct |
21 ms |
2304 KB |
Output is correct |
77 |
Correct |
77 ms |
3840 KB |
Output is correct |
78 |
Correct |
10 ms |
1408 KB |
Output is correct |
79 |
Correct |
39 ms |
2048 KB |
Output is correct |
80 |
Correct |
21 ms |
2304 KB |
Output is correct |
81 |
Correct |
74 ms |
3840 KB |
Output is correct |
82 |
Correct |
7 ms |
768 KB |
Output is correct |
83 |
Correct |
41 ms |
2048 KB |
Output is correct |
84 |
Correct |
44 ms |
3200 KB |
Output is correct |
85 |
Correct |
7 ms |
768 KB |
Output is correct |
86 |
Correct |
43 ms |
3200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
11 ms |
1408 KB |
Output is correct |
4 |
Correct |
10 ms |
1408 KB |
Output is correct |
5 |
Correct |
11 ms |
1408 KB |
Output is correct |
6 |
Correct |
11 ms |
1408 KB |
Output is correct |
7 |
Correct |
11 ms |
1408 KB |
Output is correct |
8 |
Correct |
6 ms |
896 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
6 ms |
896 KB |
Output is correct |
11 |
Correct |
11 ms |
1408 KB |
Output is correct |
12 |
Correct |
13 ms |
1664 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
11 ms |
1408 KB |
Output is correct |
15 |
Correct |
4 ms |
384 KB |
Output is correct |
16 |
Correct |
11 ms |
1408 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
11 ms |
1408 KB |
Output is correct |
19 |
Correct |
7 ms |
896 KB |
Output is correct |
20 |
Correct |
10 ms |
1152 KB |
Output is correct |
21 |
Correct |
8 ms |
1152 KB |
Output is correct |
22 |
Correct |
6 ms |
896 KB |
Output is correct |
23 |
Correct |
12 ms |
1536 KB |
Output is correct |
24 |
Correct |
6 ms |
896 KB |
Output is correct |
25 |
Correct |
12 ms |
1536 KB |
Output is correct |
26 |
Correct |
11 ms |
1536 KB |
Output is correct |
27 |
Correct |
10 ms |
1408 KB |
Output is correct |
28 |
Correct |
12 ms |
1536 KB |
Output is correct |
29 |
Correct |
10 ms |
1408 KB |
Output is correct |
30 |
Correct |
13 ms |
1536 KB |
Output is correct |
31 |
Correct |
13 ms |
1536 KB |
Output is correct |
32 |
Correct |
13 ms |
1536 KB |
Output is correct |
33 |
Correct |
12 ms |
1664 KB |
Output is correct |
34 |
Correct |
14 ms |
1536 KB |
Output is correct |
35 |
Correct |
8 ms |
1024 KB |
Output is correct |
36 |
Correct |
8 ms |
896 KB |
Output is correct |
37 |
Correct |
8 ms |
896 KB |
Output is correct |
38 |
Correct |
7 ms |
768 KB |
Output is correct |
39 |
Correct |
7 ms |
768 KB |
Output is correct |
40 |
Correct |
16 ms |
1920 KB |
Output is correct |
41 |
Correct |
7 ms |
768 KB |
Output is correct |
42 |
Correct |
16 ms |
1920 KB |
Output is correct |
43 |
Correct |
17 ms |
1920 KB |
Output is correct |
44 |
Correct |
5 ms |
384 KB |
Output is correct |
45 |
Correct |
262 ms |
21756 KB |
Output is correct |
46 |
Correct |
120 ms |
13816 KB |
Output is correct |
47 |
Correct |
267 ms |
21700 KB |
Output is correct |
48 |
Correct |
251 ms |
21752 KB |
Output is correct |
49 |
Correct |
82 ms |
11128 KB |
Output is correct |
50 |
Correct |
292 ms |
27076 KB |
Output is correct |
51 |
Correct |
258 ms |
21724 KB |
Output is correct |
52 |
Correct |
78 ms |
11128 KB |
Output is correct |
53 |
Correct |
85 ms |
11128 KB |
Output is correct |
54 |
Correct |
25 ms |
5888 KB |
Output is correct |
55 |
Correct |
295 ms |
27000 KB |
Output is correct |
56 |
Correct |
48 ms |
8576 KB |
Output is correct |
57 |
Correct |
78 ms |
11128 KB |
Output is correct |
58 |
Correct |
95 ms |
13816 KB |
Output is correct |
59 |
Correct |
49 ms |
8576 KB |
Output is correct |
60 |
Correct |
48 ms |
8576 KB |
Output is correct |
61 |
Correct |
101 ms |
13816 KB |
Output is correct |
62 |
Correct |
74 ms |
11168 KB |
Output is correct |
63 |
Correct |
142 ms |
15232 KB |
Output is correct |
64 |
Correct |
47 ms |
8576 KB |
Output is correct |
65 |
Correct |
186 ms |
17784 KB |
Output is correct |
66 |
Correct |
70 ms |
11128 KB |
Output is correct |
67 |
Correct |
141 ms |
15096 KB |
Output is correct |
68 |
Correct |
171 ms |
17144 KB |
Output is correct |
69 |
Correct |
188 ms |
17788 KB |
Output is correct |
70 |
Correct |
79 ms |
11132 KB |
Output is correct |
71 |
Correct |
183 ms |
17072 KB |
Output is correct |
72 |
Correct |
139 ms |
14712 KB |
Output is correct |
73 |
Correct |
208 ms |
19448 KB |
Output is correct |
74 |
Correct |
79 ms |
11128 KB |
Output is correct |
75 |
Correct |
72 ms |
8184 KB |
Output is correct |
76 |
Correct |
136 ms |
14712 KB |
Output is correct |
77 |
Correct |
209 ms |
19452 KB |
Output is correct |
78 |
Correct |
97 ms |
9848 KB |
Output is correct |
79 |
Correct |
69 ms |
8184 KB |
Output is correct |
80 |
Correct |
39 ms |
4352 KB |
Output is correct |
81 |
Correct |
95 ms |
9848 KB |
Output is correct |
82 |
Correct |
155 ms |
16376 KB |
Output is correct |
83 |
Correct |
35 ms |
4256 KB |
Output is correct |
84 |
Correct |
151 ms |
16376 KB |
Output is correct |