#include <bits/stdc++.h>
#define DIM 50010
using namespace std;
priority_queue <pair<int,int>, vector <pair<int,int> >, greater<pair<int,int> > > H;
set <int> L[DIM];
int n,k,i,j,sol,el,nod;
int v[DIM],x[DIM],viz[DIM],f[DIM],g[DIM];
int verif (int pas, int nod){
for (int i=1;i<pas;i++){
int vecin = x[i];
if (L[nod].find(vecin) == L[nod].end())
return 0;
if (L[vecin].find(nod) == L[vecin].end())
return 0;
}
return 1;
}
void back (int pas){
sol = max (sol,pas-1);
if (pas >= k)
return;
for (int i=1;i<=el;i++){
if (!f[i] && v[i] > x[pas-1] && verif(pas,v[i])){
x[pas] = v[i];
f[i] = 1;
back(pas+1);
f[i] = 0;
}
}
}
void get_max_clique (int nod){
el = 0;
for (auto vecin:L[nod])
v[++el] = vecin;
sort (v+1,v+el+1);
back (1);
}
int main (){
//ifstream cin ("date.in");
//ofstream cout ("date.out");
cin>>n>>k;
for (i=1;i<=n;i++){
cin>>g[i];
for (j=1;j<=g[i];j++){
cin>>nod;
L[i].insert(nod+1);
}
H.push (make_pair(g[i],i));
}
while (!H.empty()){
int nod = H.top().second;
int grad = H.top().first;
H.pop();
if (grad != g[nod]) /// inseamna ca nu e ala cu gradul minim
continue;
/// vreau sa gasesc clica maxima din care poate face parte nod
get_max_clique (nod);
viz[nod] = 1;
/// acum il elimin pe nod si toate muchiile
for (auto vecin:L[nod]){
if (viz[vecin])
continue;
/// nu am incercat sa obtin clica de aici deloc
viz[vecin] = 1;
g[vecin]--;
L[vecin].erase(L[vecin].find(nod));
H.push(make_pair(g[vecin],vecin));
}
L[nod].clear();
}
cout<<sol+1;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2680 KB |
Output is correct |
2 |
Correct |
4 ms |
2680 KB |
Output is correct |
3 |
Correct |
14 ms |
3192 KB |
Output is correct |
4 |
Correct |
13 ms |
3320 KB |
Output is correct |
5 |
Correct |
13 ms |
3320 KB |
Output is correct |
6 |
Correct |
12 ms |
3192 KB |
Output is correct |
7 |
Correct |
12 ms |
3192 KB |
Output is correct |
8 |
Correct |
6 ms |
2808 KB |
Output is correct |
9 |
Correct |
4 ms |
2680 KB |
Output is correct |
10 |
Correct |
6 ms |
2808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2680 KB |
Output is correct |
2 |
Correct |
4 ms |
2680 KB |
Output is correct |
3 |
Correct |
14 ms |
3192 KB |
Output is correct |
4 |
Correct |
13 ms |
3320 KB |
Output is correct |
5 |
Correct |
13 ms |
3320 KB |
Output is correct |
6 |
Correct |
12 ms |
3192 KB |
Output is correct |
7 |
Correct |
12 ms |
3192 KB |
Output is correct |
8 |
Correct |
6 ms |
2808 KB |
Output is correct |
9 |
Correct |
4 ms |
2680 KB |
Output is correct |
10 |
Correct |
6 ms |
2808 KB |
Output is correct |
11 |
Correct |
13 ms |
3192 KB |
Output is correct |
12 |
Correct |
93 ms |
3320 KB |
Output is correct |
13 |
Correct |
4 ms |
2680 KB |
Output is correct |
14 |
Correct |
94 ms |
3424 KB |
Output is correct |
15 |
Correct |
4 ms |
2680 KB |
Output is correct |
16 |
Correct |
14 ms |
3192 KB |
Output is correct |
17 |
Correct |
4 ms |
2680 KB |
Output is correct |
18 |
Correct |
13 ms |
3192 KB |
Output is correct |
19 |
Correct |
6 ms |
2808 KB |
Output is correct |
20 |
Correct |
9 ms |
2940 KB |
Output is correct |
21 |
Correct |
9 ms |
2936 KB |
Output is correct |
22 |
Correct |
6 ms |
2808 KB |
Output is correct |
23 |
Correct |
15 ms |
3320 KB |
Output is correct |
24 |
Correct |
6 ms |
2808 KB |
Output is correct |
25 |
Correct |
15 ms |
3320 KB |
Output is correct |
26 |
Correct |
14 ms |
3320 KB |
Output is correct |
27 |
Correct |
13 ms |
3192 KB |
Output is correct |
28 |
Correct |
14 ms |
3320 KB |
Output is correct |
29 |
Correct |
13 ms |
3192 KB |
Output is correct |
30 |
Correct |
33 ms |
3320 KB |
Output is correct |
31 |
Correct |
15 ms |
3320 KB |
Output is correct |
32 |
Correct |
33 ms |
3320 KB |
Output is correct |
33 |
Correct |
16 ms |
3332 KB |
Output is correct |
34 |
Correct |
15 ms |
3320 KB |
Output is correct |
35 |
Correct |
9 ms |
3192 KB |
Output is correct |
36 |
Correct |
9 ms |
3064 KB |
Output is correct |
37 |
Correct |
9 ms |
3064 KB |
Output is correct |
38 |
Correct |
7 ms |
2936 KB |
Output is correct |
39 |
Correct |
8 ms |
2936 KB |
Output is correct |
40 |
Correct |
20 ms |
3704 KB |
Output is correct |
41 |
Correct |
8 ms |
2936 KB |
Output is correct |
42 |
Correct |
21 ms |
3676 KB |
Output is correct |
43 |
Correct |
21 ms |
3704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2808 KB |
Output is correct |
2 |
Correct |
4 ms |
2680 KB |
Output is correct |
3 |
Correct |
4 ms |
2680 KB |
Output is correct |
4 |
Correct |
4 ms |
2680 KB |
Output is correct |
5 |
Correct |
4 ms |
2680 KB |
Output is correct |
6 |
Correct |
4 ms |
2680 KB |
Output is correct |
7 |
Correct |
4 ms |
2680 KB |
Output is correct |
8 |
Correct |
4 ms |
2680 KB |
Output is correct |
9 |
Correct |
4 ms |
2680 KB |
Output is correct |
10 |
Correct |
4 ms |
2680 KB |
Output is correct |
11 |
Correct |
504 ms |
25200 KB |
Output is correct |
12 |
Correct |
5 ms |
2680 KB |
Output is correct |
13 |
Correct |
450 ms |
25200 KB |
Output is correct |
14 |
Correct |
4 ms |
2680 KB |
Output is correct |
15 |
Correct |
510 ms |
25304 KB |
Output is correct |
16 |
Correct |
447 ms |
25360 KB |
Output is correct |
17 |
Correct |
448 ms |
25316 KB |
Output is correct |
18 |
Correct |
451 ms |
25328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2680 KB |
Output is correct |
2 |
Correct |
4 ms |
2680 KB |
Output is correct |
3 |
Correct |
14 ms |
3192 KB |
Output is correct |
4 |
Correct |
13 ms |
3320 KB |
Output is correct |
5 |
Correct |
13 ms |
3320 KB |
Output is correct |
6 |
Correct |
12 ms |
3192 KB |
Output is correct |
7 |
Correct |
12 ms |
3192 KB |
Output is correct |
8 |
Correct |
6 ms |
2808 KB |
Output is correct |
9 |
Correct |
4 ms |
2680 KB |
Output is correct |
10 |
Correct |
6 ms |
2808 KB |
Output is correct |
11 |
Correct |
13 ms |
3192 KB |
Output is correct |
12 |
Correct |
93 ms |
3320 KB |
Output is correct |
13 |
Correct |
4 ms |
2680 KB |
Output is correct |
14 |
Correct |
94 ms |
3424 KB |
Output is correct |
15 |
Correct |
4 ms |
2680 KB |
Output is correct |
16 |
Correct |
14 ms |
3192 KB |
Output is correct |
17 |
Correct |
4 ms |
2680 KB |
Output is correct |
18 |
Correct |
13 ms |
3192 KB |
Output is correct |
19 |
Correct |
6 ms |
2808 KB |
Output is correct |
20 |
Correct |
9 ms |
2940 KB |
Output is correct |
21 |
Correct |
9 ms |
2936 KB |
Output is correct |
22 |
Correct |
6 ms |
2808 KB |
Output is correct |
23 |
Correct |
15 ms |
3320 KB |
Output is correct |
24 |
Correct |
6 ms |
2808 KB |
Output is correct |
25 |
Correct |
15 ms |
3320 KB |
Output is correct |
26 |
Correct |
14 ms |
3320 KB |
Output is correct |
27 |
Correct |
13 ms |
3192 KB |
Output is correct |
28 |
Correct |
14 ms |
3320 KB |
Output is correct |
29 |
Correct |
13 ms |
3192 KB |
Output is correct |
30 |
Correct |
33 ms |
3320 KB |
Output is correct |
31 |
Correct |
15 ms |
3320 KB |
Output is correct |
32 |
Correct |
33 ms |
3320 KB |
Output is correct |
33 |
Correct |
16 ms |
3332 KB |
Output is correct |
34 |
Correct |
15 ms |
3320 KB |
Output is correct |
35 |
Correct |
9 ms |
3192 KB |
Output is correct |
36 |
Correct |
9 ms |
3064 KB |
Output is correct |
37 |
Correct |
9 ms |
3064 KB |
Output is correct |
38 |
Correct |
7 ms |
2936 KB |
Output is correct |
39 |
Correct |
8 ms |
2936 KB |
Output is correct |
40 |
Correct |
20 ms |
3704 KB |
Output is correct |
41 |
Correct |
8 ms |
2936 KB |
Output is correct |
42 |
Correct |
21 ms |
3676 KB |
Output is correct |
43 |
Correct |
21 ms |
3704 KB |
Output is correct |
44 |
Correct |
67 ms |
4728 KB |
Output is correct |
45 |
Correct |
4 ms |
2680 KB |
Output is correct |
46 |
Correct |
21 ms |
3704 KB |
Output is correct |
47 |
Correct |
39 ms |
4600 KB |
Output is correct |
48 |
Correct |
21 ms |
3832 KB |
Output is correct |
49 |
Correct |
44 ms |
4856 KB |
Output is correct |
50 |
Correct |
41 ms |
4732 KB |
Output is correct |
51 |
Correct |
91 ms |
7032 KB |
Output is correct |
52 |
Correct |
13 ms |
3336 KB |
Output is correct |
53 |
Correct |
794 ms |
7600 KB |
Output is correct |
54 |
Correct |
111 ms |
7416 KB |
Output is correct |
55 |
Correct |
15 ms |
3320 KB |
Output is correct |
56 |
Correct |
13 ms |
3324 KB |
Output is correct |
57 |
Correct |
6 ms |
2808 KB |
Output is correct |
58 |
Correct |
789 ms |
7672 KB |
Output is correct |
59 |
Correct |
20 ms |
3752 KB |
Output is correct |
60 |
Correct |
11 ms |
3320 KB |
Output is correct |
61 |
Correct |
22 ms |
3848 KB |
Output is correct |
62 |
Correct |
20 ms |
3832 KB |
Output is correct |
63 |
Correct |
66 ms |
4856 KB |
Output is correct |
64 |
Correct |
46 ms |
4516 KB |
Output is correct |
65 |
Correct |
19 ms |
3708 KB |
Output is correct |
66 |
Correct |
20 ms |
3832 KB |
Output is correct |
67 |
Correct |
58 ms |
5240 KB |
Output is correct |
68 |
Correct |
46 ms |
4600 KB |
Output is correct |
69 |
Correct |
19 ms |
3664 KB |
Output is correct |
70 |
Correct |
36 ms |
4600 KB |
Output is correct |
71 |
Correct |
57 ms |
5240 KB |
Output is correct |
72 |
Correct |
51 ms |
5240 KB |
Output is correct |
73 |
Correct |
13 ms |
3320 KB |
Output is correct |
74 |
Correct |
36 ms |
4728 KB |
Output is correct |
75 |
Correct |
50 ms |
5240 KB |
Output is correct |
76 |
Correct |
45 ms |
4216 KB |
Output is correct |
77 |
Correct |
56 ms |
5752 KB |
Output is correct |
78 |
Correct |
13 ms |
3320 KB |
Output is correct |
79 |
Correct |
27 ms |
4216 KB |
Output is correct |
80 |
Correct |
44 ms |
4088 KB |
Output is correct |
81 |
Correct |
53 ms |
5752 KB |
Output is correct |
82 |
Correct |
8 ms |
2936 KB |
Output is correct |
83 |
Correct |
31 ms |
4216 KB |
Output is correct |
84 |
Correct |
41 ms |
5160 KB |
Output is correct |
85 |
Correct |
8 ms |
2940 KB |
Output is correct |
86 |
Correct |
42 ms |
5240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2680 KB |
Output is correct |
2 |
Correct |
4 ms |
2680 KB |
Output is correct |
3 |
Correct |
14 ms |
3192 KB |
Output is correct |
4 |
Correct |
13 ms |
3320 KB |
Output is correct |
5 |
Correct |
13 ms |
3320 KB |
Output is correct |
6 |
Correct |
12 ms |
3192 KB |
Output is correct |
7 |
Correct |
12 ms |
3192 KB |
Output is correct |
8 |
Correct |
6 ms |
2808 KB |
Output is correct |
9 |
Correct |
4 ms |
2680 KB |
Output is correct |
10 |
Correct |
6 ms |
2808 KB |
Output is correct |
11 |
Correct |
13 ms |
3192 KB |
Output is correct |
12 |
Correct |
93 ms |
3320 KB |
Output is correct |
13 |
Correct |
4 ms |
2680 KB |
Output is correct |
14 |
Correct |
94 ms |
3424 KB |
Output is correct |
15 |
Correct |
4 ms |
2680 KB |
Output is correct |
16 |
Correct |
14 ms |
3192 KB |
Output is correct |
17 |
Correct |
4 ms |
2680 KB |
Output is correct |
18 |
Correct |
13 ms |
3192 KB |
Output is correct |
19 |
Correct |
6 ms |
2808 KB |
Output is correct |
20 |
Correct |
9 ms |
2940 KB |
Output is correct |
21 |
Correct |
9 ms |
2936 KB |
Output is correct |
22 |
Correct |
6 ms |
2808 KB |
Output is correct |
23 |
Correct |
15 ms |
3320 KB |
Output is correct |
24 |
Correct |
6 ms |
2808 KB |
Output is correct |
25 |
Correct |
15 ms |
3320 KB |
Output is correct |
26 |
Correct |
14 ms |
3320 KB |
Output is correct |
27 |
Correct |
13 ms |
3192 KB |
Output is correct |
28 |
Correct |
14 ms |
3320 KB |
Output is correct |
29 |
Correct |
13 ms |
3192 KB |
Output is correct |
30 |
Correct |
33 ms |
3320 KB |
Output is correct |
31 |
Correct |
15 ms |
3320 KB |
Output is correct |
32 |
Correct |
33 ms |
3320 KB |
Output is correct |
33 |
Correct |
16 ms |
3332 KB |
Output is correct |
34 |
Correct |
15 ms |
3320 KB |
Output is correct |
35 |
Correct |
9 ms |
3192 KB |
Output is correct |
36 |
Correct |
9 ms |
3064 KB |
Output is correct |
37 |
Correct |
9 ms |
3064 KB |
Output is correct |
38 |
Correct |
7 ms |
2936 KB |
Output is correct |
39 |
Correct |
8 ms |
2936 KB |
Output is correct |
40 |
Correct |
20 ms |
3704 KB |
Output is correct |
41 |
Correct |
8 ms |
2936 KB |
Output is correct |
42 |
Correct |
21 ms |
3676 KB |
Output is correct |
43 |
Correct |
21 ms |
3704 KB |
Output is correct |
44 |
Correct |
4 ms |
2680 KB |
Output is correct |
45 |
Correct |
314 ms |
17668 KB |
Output is correct |
46 |
Correct |
2139 ms |
11892 KB |
Output is correct |
47 |
Correct |
318 ms |
19700 KB |
Output is correct |
48 |
Correct |
317 ms |
19440 KB |
Output is correct |
49 |
Correct |
111 ms |
9200 KB |
Output is correct |
50 |
Execution timed out |
3068 ms |
24992 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |