#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e4 + 10;
const int INF = 0x3f3f3f3f;
set<pair<int, int> > verts;
array<set<int>, MAXN> grafo;
vector<int> active;
int grau[MAXN];
int resp = 0;
void bt(set<int>::iterator it, int v)
{
if (it == grafo[v].end())
{
resp = max(resp, (int)active.size()+1);
return;
}
// cerr << *it << '\n';
auto aux = it;
bt(++aux, v);
for (auto viz : active) if (grafo[*it].find(viz) == grafo[*it].end()) return;
active.push_back(*it);
aux = it;
bt(++aux, v);
active.pop_back();
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N, K;
cin >> N >> K;
for (int i = 0; i < N; i++)
{
cin >> grau[i];
for (int j = 0; j < grau[i]; j++)
{
int X;
cin >> X;
grafo[i].insert(X);
}
verts.emplace(grau[i], i);
}
while (!verts.empty())
{
// for (auto [g, id] : verts) cerr << "||" << g << " " << id << " ";
// cerr << '\n';
int cur = verts.begin()->second; verts.erase(verts.begin());
bt(grafo[cur].begin(), cur);
for (auto viz : grafo[cur])
{
grafo[viz].erase(cur);
verts.erase(make_pair(grau[viz], viz));
grau[viz]--;
verts.emplace(grau[viz], viz);
}
grafo[cur].clear(); grau[cur] = INF;
}
cout << resp << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
5 ms |
3408 KB |
Output is correct |
4 |
Correct |
4 ms |
3412 KB |
Output is correct |
5 |
Correct |
5 ms |
3404 KB |
Output is correct |
6 |
Correct |
5 ms |
3348 KB |
Output is correct |
7 |
Correct |
5 ms |
3412 KB |
Output is correct |
8 |
Correct |
2 ms |
2936 KB |
Output is correct |
9 |
Correct |
1 ms |
2572 KB |
Output is correct |
10 |
Correct |
3 ms |
2900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
5 ms |
3408 KB |
Output is correct |
4 |
Correct |
4 ms |
3412 KB |
Output is correct |
5 |
Correct |
5 ms |
3404 KB |
Output is correct |
6 |
Correct |
5 ms |
3348 KB |
Output is correct |
7 |
Correct |
5 ms |
3412 KB |
Output is correct |
8 |
Correct |
2 ms |
2936 KB |
Output is correct |
9 |
Correct |
1 ms |
2572 KB |
Output is correct |
10 |
Correct |
3 ms |
2900 KB |
Output is correct |
11 |
Correct |
5 ms |
3412 KB |
Output is correct |
12 |
Correct |
6 ms |
3412 KB |
Output is correct |
13 |
Correct |
1 ms |
2644 KB |
Output is correct |
14 |
Correct |
5 ms |
3360 KB |
Output is correct |
15 |
Correct |
2 ms |
2644 KB |
Output is correct |
16 |
Correct |
5 ms |
3412 KB |
Output is correct |
17 |
Correct |
2 ms |
2644 KB |
Output is correct |
18 |
Correct |
6 ms |
3412 KB |
Output is correct |
19 |
Correct |
2 ms |
2900 KB |
Output is correct |
20 |
Correct |
3 ms |
3156 KB |
Output is correct |
21 |
Correct |
4 ms |
3200 KB |
Output is correct |
22 |
Correct |
3 ms |
2900 KB |
Output is correct |
23 |
Correct |
6 ms |
3540 KB |
Output is correct |
24 |
Correct |
2 ms |
2900 KB |
Output is correct |
25 |
Correct |
6 ms |
3540 KB |
Output is correct |
26 |
Correct |
5 ms |
3460 KB |
Output is correct |
27 |
Correct |
4 ms |
3412 KB |
Output is correct |
28 |
Correct |
5 ms |
3452 KB |
Output is correct |
29 |
Correct |
4 ms |
3412 KB |
Output is correct |
30 |
Correct |
6 ms |
3540 KB |
Output is correct |
31 |
Correct |
5 ms |
3584 KB |
Output is correct |
32 |
Correct |
6 ms |
3632 KB |
Output is correct |
33 |
Correct |
8 ms |
3668 KB |
Output is correct |
34 |
Correct |
5 ms |
3540 KB |
Output is correct |
35 |
Correct |
3 ms |
3028 KB |
Output is correct |
36 |
Correct |
3 ms |
3028 KB |
Output is correct |
37 |
Correct |
4 ms |
3028 KB |
Output is correct |
38 |
Correct |
4 ms |
2900 KB |
Output is correct |
39 |
Correct |
4 ms |
2948 KB |
Output is correct |
40 |
Correct |
10 ms |
3924 KB |
Output is correct |
41 |
Correct |
4 ms |
2900 KB |
Output is correct |
42 |
Correct |
8 ms |
3924 KB |
Output is correct |
43 |
Correct |
8 ms |
3968 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2900 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 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 |
2680 KB |
Output is correct |
9 |
Correct |
2 ms |
2644 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
11 |
Correct |
282 ms |
28972 KB |
Output is correct |
12 |
Correct |
2 ms |
2644 KB |
Output is correct |
13 |
Correct |
291 ms |
29000 KB |
Output is correct |
14 |
Correct |
2 ms |
2672 KB |
Output is correct |
15 |
Correct |
261 ms |
28876 KB |
Output is correct |
16 |
Correct |
291 ms |
28876 KB |
Output is correct |
17 |
Correct |
314 ms |
28960 KB |
Output is correct |
18 |
Correct |
276 ms |
28976 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
5 ms |
3408 KB |
Output is correct |
4 |
Correct |
4 ms |
3412 KB |
Output is correct |
5 |
Correct |
5 ms |
3404 KB |
Output is correct |
6 |
Correct |
5 ms |
3348 KB |
Output is correct |
7 |
Correct |
5 ms |
3412 KB |
Output is correct |
8 |
Correct |
2 ms |
2936 KB |
Output is correct |
9 |
Correct |
1 ms |
2572 KB |
Output is correct |
10 |
Correct |
3 ms |
2900 KB |
Output is correct |
11 |
Correct |
5 ms |
3412 KB |
Output is correct |
12 |
Correct |
6 ms |
3412 KB |
Output is correct |
13 |
Correct |
1 ms |
2644 KB |
Output is correct |
14 |
Correct |
5 ms |
3360 KB |
Output is correct |
15 |
Correct |
2 ms |
2644 KB |
Output is correct |
16 |
Correct |
5 ms |
3412 KB |
Output is correct |
17 |
Correct |
2 ms |
2644 KB |
Output is correct |
18 |
Correct |
6 ms |
3412 KB |
Output is correct |
19 |
Correct |
2 ms |
2900 KB |
Output is correct |
20 |
Correct |
3 ms |
3156 KB |
Output is correct |
21 |
Correct |
4 ms |
3200 KB |
Output is correct |
22 |
Correct |
3 ms |
2900 KB |
Output is correct |
23 |
Correct |
6 ms |
3540 KB |
Output is correct |
24 |
Correct |
2 ms |
2900 KB |
Output is correct |
25 |
Correct |
6 ms |
3540 KB |
Output is correct |
26 |
Correct |
5 ms |
3460 KB |
Output is correct |
27 |
Correct |
4 ms |
3412 KB |
Output is correct |
28 |
Correct |
5 ms |
3452 KB |
Output is correct |
29 |
Correct |
4 ms |
3412 KB |
Output is correct |
30 |
Correct |
6 ms |
3540 KB |
Output is correct |
31 |
Correct |
5 ms |
3584 KB |
Output is correct |
32 |
Correct |
6 ms |
3632 KB |
Output is correct |
33 |
Correct |
8 ms |
3668 KB |
Output is correct |
34 |
Correct |
5 ms |
3540 KB |
Output is correct |
35 |
Correct |
3 ms |
3028 KB |
Output is correct |
36 |
Correct |
3 ms |
3028 KB |
Output is correct |
37 |
Correct |
4 ms |
3028 KB |
Output is correct |
38 |
Correct |
4 ms |
2900 KB |
Output is correct |
39 |
Correct |
4 ms |
2948 KB |
Output is correct |
40 |
Correct |
10 ms |
3924 KB |
Output is correct |
41 |
Correct |
4 ms |
2900 KB |
Output is correct |
42 |
Correct |
8 ms |
3924 KB |
Output is correct |
43 |
Correct |
8 ms |
3968 KB |
Output is correct |
44 |
Correct |
24 ms |
4948 KB |
Output is correct |
45 |
Correct |
1 ms |
2644 KB |
Output is correct |
46 |
Correct |
9 ms |
3968 KB |
Output is correct |
47 |
Correct |
16 ms |
5000 KB |
Output is correct |
48 |
Correct |
11 ms |
3964 KB |
Output is correct |
49 |
Correct |
15 ms |
4884 KB |
Output is correct |
50 |
Correct |
16 ms |
4948 KB |
Output is correct |
51 |
Correct |
33 ms |
6996 KB |
Output is correct |
52 |
Correct |
5 ms |
3332 KB |
Output is correct |
53 |
Correct |
27 ms |
7508 KB |
Output is correct |
54 |
Correct |
43 ms |
7508 KB |
Output is correct |
55 |
Correct |
5 ms |
3452 KB |
Output is correct |
56 |
Correct |
5 ms |
3540 KB |
Output is correct |
57 |
Correct |
2 ms |
2900 KB |
Output is correct |
58 |
Correct |
25 ms |
7508 KB |
Output is correct |
59 |
Correct |
6 ms |
3924 KB |
Output is correct |
60 |
Correct |
5 ms |
3412 KB |
Output is correct |
61 |
Correct |
7 ms |
3924 KB |
Output is correct |
62 |
Correct |
8 ms |
3964 KB |
Output is correct |
63 |
Correct |
23 ms |
5008 KB |
Output is correct |
64 |
Correct |
15 ms |
4692 KB |
Output is correct |
65 |
Correct |
7 ms |
3796 KB |
Output is correct |
66 |
Correct |
6 ms |
3924 KB |
Output is correct |
67 |
Correct |
21 ms |
5344 KB |
Output is correct |
68 |
Correct |
15 ms |
4748 KB |
Output is correct |
69 |
Correct |
7 ms |
3796 KB |
Output is correct |
70 |
Correct |
15 ms |
4712 KB |
Output is correct |
71 |
Correct |
21 ms |
5396 KB |
Output is correct |
72 |
Correct |
19 ms |
5196 KB |
Output is correct |
73 |
Correct |
4 ms |
3460 KB |
Output is correct |
74 |
Correct |
16 ms |
4820 KB |
Output is correct |
75 |
Correct |
20 ms |
5244 KB |
Output is correct |
76 |
Correct |
10 ms |
4220 KB |
Output is correct |
77 |
Correct |
23 ms |
5876 KB |
Output is correct |
78 |
Correct |
5 ms |
3348 KB |
Output is correct |
79 |
Correct |
12 ms |
4280 KB |
Output is correct |
80 |
Correct |
10 ms |
4308 KB |
Output is correct |
81 |
Correct |
23 ms |
5844 KB |
Output is correct |
82 |
Correct |
3 ms |
2940 KB |
Output is correct |
83 |
Correct |
12 ms |
4180 KB |
Output is correct |
84 |
Correct |
17 ms |
5248 KB |
Output is correct |
85 |
Correct |
3 ms |
2904 KB |
Output is correct |
86 |
Correct |
17 ms |
5156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
5 ms |
3408 KB |
Output is correct |
4 |
Correct |
4 ms |
3412 KB |
Output is correct |
5 |
Correct |
5 ms |
3404 KB |
Output is correct |
6 |
Correct |
5 ms |
3348 KB |
Output is correct |
7 |
Correct |
5 ms |
3412 KB |
Output is correct |
8 |
Correct |
2 ms |
2936 KB |
Output is correct |
9 |
Correct |
1 ms |
2572 KB |
Output is correct |
10 |
Correct |
3 ms |
2900 KB |
Output is correct |
11 |
Correct |
5 ms |
3412 KB |
Output is correct |
12 |
Correct |
6 ms |
3412 KB |
Output is correct |
13 |
Correct |
1 ms |
2644 KB |
Output is correct |
14 |
Correct |
5 ms |
3360 KB |
Output is correct |
15 |
Correct |
2 ms |
2644 KB |
Output is correct |
16 |
Correct |
5 ms |
3412 KB |
Output is correct |
17 |
Correct |
2 ms |
2644 KB |
Output is correct |
18 |
Correct |
6 ms |
3412 KB |
Output is correct |
19 |
Correct |
2 ms |
2900 KB |
Output is correct |
20 |
Correct |
3 ms |
3156 KB |
Output is correct |
21 |
Correct |
4 ms |
3200 KB |
Output is correct |
22 |
Correct |
3 ms |
2900 KB |
Output is correct |
23 |
Correct |
6 ms |
3540 KB |
Output is correct |
24 |
Correct |
2 ms |
2900 KB |
Output is correct |
25 |
Correct |
6 ms |
3540 KB |
Output is correct |
26 |
Correct |
5 ms |
3460 KB |
Output is correct |
27 |
Correct |
4 ms |
3412 KB |
Output is correct |
28 |
Correct |
5 ms |
3452 KB |
Output is correct |
29 |
Correct |
4 ms |
3412 KB |
Output is correct |
30 |
Correct |
6 ms |
3540 KB |
Output is correct |
31 |
Correct |
5 ms |
3584 KB |
Output is correct |
32 |
Correct |
6 ms |
3632 KB |
Output is correct |
33 |
Correct |
8 ms |
3668 KB |
Output is correct |
34 |
Correct |
5 ms |
3540 KB |
Output is correct |
35 |
Correct |
3 ms |
3028 KB |
Output is correct |
36 |
Correct |
3 ms |
3028 KB |
Output is correct |
37 |
Correct |
4 ms |
3028 KB |
Output is correct |
38 |
Correct |
4 ms |
2900 KB |
Output is correct |
39 |
Correct |
4 ms |
2948 KB |
Output is correct |
40 |
Correct |
10 ms |
3924 KB |
Output is correct |
41 |
Correct |
4 ms |
2900 KB |
Output is correct |
42 |
Correct |
8 ms |
3924 KB |
Output is correct |
43 |
Correct |
8 ms |
3968 KB |
Output is correct |
44 |
Correct |
1 ms |
2644 KB |
Output is correct |
45 |
Correct |
186 ms |
21112 KB |
Output is correct |
46 |
Correct |
57 ms |
13172 KB |
Output is correct |
47 |
Correct |
174 ms |
21112 KB |
Output is correct |
48 |
Correct |
166 ms |
21068 KB |
Output is correct |
49 |
Correct |
42 ms |
10532 KB |
Output is correct |
50 |
Correct |
139 ms |
26340 KB |
Output is correct |
51 |
Correct |
162 ms |
21060 KB |
Output is correct |
52 |
Correct |
45 ms |
10496 KB |
Output is correct |
53 |
Correct |
41 ms |
10520 KB |
Output is correct |
54 |
Correct |
11 ms |
5276 KB |
Output is correct |
55 |
Correct |
146 ms |
26456 KB |
Output is correct |
56 |
Correct |
24 ms |
7888 KB |
Output is correct |
57 |
Correct |
42 ms |
10488 KB |
Output is correct |
58 |
Correct |
48 ms |
13092 KB |
Output is correct |
59 |
Correct |
23 ms |
7892 KB |
Output is correct |
60 |
Correct |
24 ms |
7816 KB |
Output is correct |
61 |
Correct |
49 ms |
13188 KB |
Output is correct |
62 |
Correct |
35 ms |
10452 KB |
Output is correct |
63 |
Correct |
82 ms |
14504 KB |
Output is correct |
64 |
Correct |
25 ms |
7948 KB |
Output is correct |
65 |
Correct |
112 ms |
17156 KB |
Output is correct |
66 |
Correct |
35 ms |
10580 KB |
Output is correct |
67 |
Correct |
85 ms |
14388 KB |
Output is correct |
68 |
Correct |
103 ms |
16464 KB |
Output is correct |
69 |
Correct |
120 ms |
17100 KB |
Output is correct |
70 |
Correct |
53 ms |
10472 KB |
Output is correct |
71 |
Correct |
106 ms |
16504 KB |
Output is correct |
72 |
Correct |
69 ms |
14076 KB |
Output is correct |
73 |
Correct |
138 ms |
18764 KB |
Output is correct |
74 |
Correct |
39 ms |
10444 KB |
Output is correct |
75 |
Correct |
38 ms |
9024 KB |
Output is correct |
76 |
Correct |
72 ms |
14028 KB |
Output is correct |
77 |
Correct |
124 ms |
18832 KB |
Output is correct |
78 |
Correct |
52 ms |
10700 KB |
Output is correct |
79 |
Correct |
38 ms |
9084 KB |
Output is correct |
80 |
Correct |
19 ms |
5844 KB |
Output is correct |
81 |
Correct |
63 ms |
10716 KB |
Output is correct |
82 |
Correct |
89 ms |
15816 KB |
Output is correct |
83 |
Correct |
18 ms |
5844 KB |
Output is correct |
84 |
Correct |
86 ms |
15820 KB |
Output is correct |