#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 |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2672 KB |
Output is correct |
3 |
Correct |
5 ms |
3412 KB |
Output is correct |
4 |
Correct |
5 ms |
3412 KB |
Output is correct |
5 |
Correct |
4 ms |
3412 KB |
Output is correct |
6 |
Correct |
5 ms |
3412 KB |
Output is correct |
7 |
Correct |
5 ms |
3452 KB |
Output is correct |
8 |
Correct |
2 ms |
2908 KB |
Output is correct |
9 |
Correct |
1 ms |
2668 KB |
Output is correct |
10 |
Correct |
2 ms |
2900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2672 KB |
Output is correct |
3 |
Correct |
5 ms |
3412 KB |
Output is correct |
4 |
Correct |
5 ms |
3412 KB |
Output is correct |
5 |
Correct |
4 ms |
3412 KB |
Output is correct |
6 |
Correct |
5 ms |
3412 KB |
Output is correct |
7 |
Correct |
5 ms |
3452 KB |
Output is correct |
8 |
Correct |
2 ms |
2908 KB |
Output is correct |
9 |
Correct |
1 ms |
2668 KB |
Output is correct |
10 |
Correct |
2 ms |
2900 KB |
Output is correct |
11 |
Correct |
4 ms |
3412 KB |
Output is correct |
12 |
Correct |
4 ms |
3452 KB |
Output is correct |
13 |
Correct |
2 ms |
2644 KB |
Output is correct |
14 |
Correct |
5 ms |
3452 KB |
Output is correct |
15 |
Correct |
1 ms |
2644 KB |
Output is correct |
16 |
Correct |
5 ms |
3460 KB |
Output is correct |
17 |
Correct |
1 ms |
2644 KB |
Output is correct |
18 |
Correct |
5 ms |
3452 KB |
Output is correct |
19 |
Correct |
2 ms |
2900 KB |
Output is correct |
20 |
Correct |
3 ms |
3156 KB |
Output is correct |
21 |
Correct |
3 ms |
3156 KB |
Output is correct |
22 |
Correct |
2 ms |
2900 KB |
Output is correct |
23 |
Correct |
5 ms |
3456 KB |
Output is correct |
24 |
Correct |
2 ms |
2940 KB |
Output is correct |
25 |
Correct |
5 ms |
3540 KB |
Output is correct |
26 |
Correct |
5 ms |
3412 KB |
Output is correct |
27 |
Correct |
4 ms |
3436 KB |
Output is correct |
28 |
Correct |
5 ms |
3412 KB |
Output is correct |
29 |
Correct |
5 ms |
3452 KB |
Output is correct |
30 |
Correct |
5 ms |
3540 KB |
Output is correct |
31 |
Correct |
5 ms |
3624 KB |
Output is correct |
32 |
Correct |
6 ms |
3620 KB |
Output is correct |
33 |
Correct |
6 ms |
3540 KB |
Output is correct |
34 |
Correct |
5 ms |
3540 KB |
Output is correct |
35 |
Correct |
3 ms |
3068 KB |
Output is correct |
36 |
Correct |
3 ms |
3028 KB |
Output is correct |
37 |
Correct |
3 ms |
3028 KB |
Output is correct |
38 |
Correct |
3 ms |
2900 KB |
Output is correct |
39 |
Correct |
3 ms |
2900 KB |
Output is correct |
40 |
Correct |
8 ms |
3980 KB |
Output is correct |
41 |
Correct |
3 ms |
2900 KB |
Output is correct |
42 |
Correct |
8 ms |
3924 KB |
Output is correct |
43 |
Correct |
8 ms |
3924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2940 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2672 KB |
Output is correct |
4 |
Correct |
2 ms |
2676 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 |
255 ms |
28864 KB |
Output is correct |
12 |
Correct |
1 ms |
2644 KB |
Output is correct |
13 |
Correct |
256 ms |
28976 KB |
Output is correct |
14 |
Correct |
1 ms |
2644 KB |
Output is correct |
15 |
Correct |
266 ms |
28972 KB |
Output is correct |
16 |
Correct |
273 ms |
28968 KB |
Output is correct |
17 |
Correct |
276 ms |
28868 KB |
Output is correct |
18 |
Correct |
264 ms |
28896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2672 KB |
Output is correct |
3 |
Correct |
5 ms |
3412 KB |
Output is correct |
4 |
Correct |
5 ms |
3412 KB |
Output is correct |
5 |
Correct |
4 ms |
3412 KB |
Output is correct |
6 |
Correct |
5 ms |
3412 KB |
Output is correct |
7 |
Correct |
5 ms |
3452 KB |
Output is correct |
8 |
Correct |
2 ms |
2908 KB |
Output is correct |
9 |
Correct |
1 ms |
2668 KB |
Output is correct |
10 |
Correct |
2 ms |
2900 KB |
Output is correct |
11 |
Correct |
4 ms |
3412 KB |
Output is correct |
12 |
Correct |
4 ms |
3452 KB |
Output is correct |
13 |
Correct |
2 ms |
2644 KB |
Output is correct |
14 |
Correct |
5 ms |
3452 KB |
Output is correct |
15 |
Correct |
1 ms |
2644 KB |
Output is correct |
16 |
Correct |
5 ms |
3460 KB |
Output is correct |
17 |
Correct |
1 ms |
2644 KB |
Output is correct |
18 |
Correct |
5 ms |
3452 KB |
Output is correct |
19 |
Correct |
2 ms |
2900 KB |
Output is correct |
20 |
Correct |
3 ms |
3156 KB |
Output is correct |
21 |
Correct |
3 ms |
3156 KB |
Output is correct |
22 |
Correct |
2 ms |
2900 KB |
Output is correct |
23 |
Correct |
5 ms |
3456 KB |
Output is correct |
24 |
Correct |
2 ms |
2940 KB |
Output is correct |
25 |
Correct |
5 ms |
3540 KB |
Output is correct |
26 |
Correct |
5 ms |
3412 KB |
Output is correct |
27 |
Correct |
4 ms |
3436 KB |
Output is correct |
28 |
Correct |
5 ms |
3412 KB |
Output is correct |
29 |
Correct |
5 ms |
3452 KB |
Output is correct |
30 |
Correct |
5 ms |
3540 KB |
Output is correct |
31 |
Correct |
5 ms |
3624 KB |
Output is correct |
32 |
Correct |
6 ms |
3620 KB |
Output is correct |
33 |
Correct |
6 ms |
3540 KB |
Output is correct |
34 |
Correct |
5 ms |
3540 KB |
Output is correct |
35 |
Correct |
3 ms |
3068 KB |
Output is correct |
36 |
Correct |
3 ms |
3028 KB |
Output is correct |
37 |
Correct |
3 ms |
3028 KB |
Output is correct |
38 |
Correct |
3 ms |
2900 KB |
Output is correct |
39 |
Correct |
3 ms |
2900 KB |
Output is correct |
40 |
Correct |
8 ms |
3980 KB |
Output is correct |
41 |
Correct |
3 ms |
2900 KB |
Output is correct |
42 |
Correct |
8 ms |
3924 KB |
Output is correct |
43 |
Correct |
8 ms |
3924 KB |
Output is correct |
44 |
Correct |
23 ms |
4948 KB |
Output is correct |
45 |
Correct |
1 ms |
2672 KB |
Output is correct |
46 |
Correct |
8 ms |
3924 KB |
Output is correct |
47 |
Correct |
15 ms |
5000 KB |
Output is correct |
48 |
Correct |
8 ms |
3964 KB |
Output is correct |
49 |
Correct |
15 ms |
4884 KB |
Output is correct |
50 |
Correct |
15 ms |
4868 KB |
Output is correct |
51 |
Correct |
33 ms |
6996 KB |
Output is correct |
52 |
Correct |
4 ms |
3412 KB |
Output is correct |
53 |
Correct |
25 ms |
7464 KB |
Output is correct |
54 |
Correct |
48 ms |
7516 KB |
Output is correct |
55 |
Correct |
5 ms |
3412 KB |
Output is correct |
56 |
Correct |
4 ms |
3412 KB |
Output is correct |
57 |
Correct |
2 ms |
2900 KB |
Output is correct |
58 |
Correct |
30 ms |
7636 KB |
Output is correct |
59 |
Correct |
7 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 |
6 ms |
3972 KB |
Output is correct |
63 |
Correct |
26 ms |
5004 KB |
Output is correct |
64 |
Correct |
16 ms |
4692 KB |
Output is correct |
65 |
Correct |
7 ms |
3796 KB |
Output is correct |
66 |
Correct |
6 ms |
3964 KB |
Output is correct |
67 |
Correct |
21 ms |
5332 KB |
Output is correct |
68 |
Correct |
19 ms |
4680 KB |
Output is correct |
69 |
Correct |
7 ms |
3796 KB |
Output is correct |
70 |
Correct |
14 ms |
4792 KB |
Output is correct |
71 |
Correct |
21 ms |
5352 KB |
Output is correct |
72 |
Correct |
19 ms |
5316 KB |
Output is correct |
73 |
Correct |
4 ms |
3412 KB |
Output is correct |
74 |
Correct |
15 ms |
4820 KB |
Output is correct |
75 |
Correct |
19 ms |
5240 KB |
Output is correct |
76 |
Correct |
10 ms |
4224 KB |
Output is correct |
77 |
Correct |
23 ms |
5856 KB |
Output is correct |
78 |
Correct |
4 ms |
3392 KB |
Output is correct |
79 |
Correct |
12 ms |
4180 KB |
Output is correct |
80 |
Correct |
10 ms |
4224 KB |
Output is correct |
81 |
Correct |
23 ms |
5900 KB |
Output is correct |
82 |
Correct |
3 ms |
2944 KB |
Output is correct |
83 |
Correct |
12 ms |
4184 KB |
Output is correct |
84 |
Correct |
17 ms |
5264 KB |
Output is correct |
85 |
Correct |
3 ms |
2900 KB |
Output is correct |
86 |
Correct |
17 ms |
5268 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2672 KB |
Output is correct |
3 |
Correct |
5 ms |
3412 KB |
Output is correct |
4 |
Correct |
5 ms |
3412 KB |
Output is correct |
5 |
Correct |
4 ms |
3412 KB |
Output is correct |
6 |
Correct |
5 ms |
3412 KB |
Output is correct |
7 |
Correct |
5 ms |
3452 KB |
Output is correct |
8 |
Correct |
2 ms |
2908 KB |
Output is correct |
9 |
Correct |
1 ms |
2668 KB |
Output is correct |
10 |
Correct |
2 ms |
2900 KB |
Output is correct |
11 |
Correct |
4 ms |
3412 KB |
Output is correct |
12 |
Correct |
4 ms |
3452 KB |
Output is correct |
13 |
Correct |
2 ms |
2644 KB |
Output is correct |
14 |
Correct |
5 ms |
3452 KB |
Output is correct |
15 |
Correct |
1 ms |
2644 KB |
Output is correct |
16 |
Correct |
5 ms |
3460 KB |
Output is correct |
17 |
Correct |
1 ms |
2644 KB |
Output is correct |
18 |
Correct |
5 ms |
3452 KB |
Output is correct |
19 |
Correct |
2 ms |
2900 KB |
Output is correct |
20 |
Correct |
3 ms |
3156 KB |
Output is correct |
21 |
Correct |
3 ms |
3156 KB |
Output is correct |
22 |
Correct |
2 ms |
2900 KB |
Output is correct |
23 |
Correct |
5 ms |
3456 KB |
Output is correct |
24 |
Correct |
2 ms |
2940 KB |
Output is correct |
25 |
Correct |
5 ms |
3540 KB |
Output is correct |
26 |
Correct |
5 ms |
3412 KB |
Output is correct |
27 |
Correct |
4 ms |
3436 KB |
Output is correct |
28 |
Correct |
5 ms |
3412 KB |
Output is correct |
29 |
Correct |
5 ms |
3452 KB |
Output is correct |
30 |
Correct |
5 ms |
3540 KB |
Output is correct |
31 |
Correct |
5 ms |
3624 KB |
Output is correct |
32 |
Correct |
6 ms |
3620 KB |
Output is correct |
33 |
Correct |
6 ms |
3540 KB |
Output is correct |
34 |
Correct |
5 ms |
3540 KB |
Output is correct |
35 |
Correct |
3 ms |
3068 KB |
Output is correct |
36 |
Correct |
3 ms |
3028 KB |
Output is correct |
37 |
Correct |
3 ms |
3028 KB |
Output is correct |
38 |
Correct |
3 ms |
2900 KB |
Output is correct |
39 |
Correct |
3 ms |
2900 KB |
Output is correct |
40 |
Correct |
8 ms |
3980 KB |
Output is correct |
41 |
Correct |
3 ms |
2900 KB |
Output is correct |
42 |
Correct |
8 ms |
3924 KB |
Output is correct |
43 |
Correct |
8 ms |
3924 KB |
Output is correct |
44 |
Correct |
1 ms |
2644 KB |
Output is correct |
45 |
Correct |
194 ms |
21012 KB |
Output is correct |
46 |
Correct |
58 ms |
13132 KB |
Output is correct |
47 |
Correct |
160 ms |
21068 KB |
Output is correct |
48 |
Correct |
190 ms |
21000 KB |
Output is correct |
49 |
Correct |
41 ms |
10496 KB |
Output is correct |
50 |
Correct |
132 ms |
26296 KB |
Output is correct |
51 |
Correct |
162 ms |
20948 KB |
Output is correct |
52 |
Correct |
39 ms |
10544 KB |
Output is correct |
53 |
Correct |
42 ms |
10500 KB |
Output is correct |
54 |
Correct |
11 ms |
5204 KB |
Output is correct |
55 |
Correct |
150 ms |
26280 KB |
Output is correct |
56 |
Correct |
24 ms |
7828 KB |
Output is correct |
57 |
Correct |
54 ms |
10476 KB |
Output is correct |
58 |
Correct |
48 ms |
13196 KB |
Output is correct |
59 |
Correct |
23 ms |
7892 KB |
Output is correct |
60 |
Correct |
26 ms |
7892 KB |
Output is correct |
61 |
Correct |
48 ms |
13132 KB |
Output is correct |
62 |
Correct |
35 ms |
10576 KB |
Output is correct |
63 |
Correct |
115 ms |
14388 KB |
Output is correct |
64 |
Correct |
23 ms |
7884 KB |
Output is correct |
65 |
Correct |
114 ms |
17100 KB |
Output is correct |
66 |
Correct |
36 ms |
10560 KB |
Output is correct |
67 |
Correct |
80 ms |
14504 KB |
Output is correct |
68 |
Correct |
102 ms |
16460 KB |
Output is correct |
69 |
Correct |
135 ms |
17180 KB |
Output is correct |
70 |
Correct |
39 ms |
10564 KB |
Output is correct |
71 |
Correct |
104 ms |
16504 KB |
Output is correct |
72 |
Correct |
79 ms |
14072 KB |
Output is correct |
73 |
Correct |
123 ms |
18700 KB |
Output is correct |
74 |
Correct |
40 ms |
10560 KB |
Output is correct |
75 |
Correct |
49 ms |
9080 KB |
Output is correct |
76 |
Correct |
71 ms |
14076 KB |
Output is correct |
77 |
Correct |
153 ms |
18820 KB |
Output is correct |
78 |
Correct |
52 ms |
10720 KB |
Output is correct |
79 |
Correct |
52 ms |
8964 KB |
Output is correct |
80 |
Correct |
20 ms |
5868 KB |
Output is correct |
81 |
Correct |
55 ms |
10720 KB |
Output is correct |
82 |
Correct |
86 ms |
15820 KB |
Output is correct |
83 |
Correct |
18 ms |
5844 KB |
Output is correct |
84 |
Correct |
115 ms |
15736 KB |
Output is correct |