#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 || pas > el)
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]){
g[vecin]--;
L[vecin].erase(L[vecin].find(nod));
if (!viz[vecin]){ /// nu am incercat sa obtin clica de aici deloc
viz[vecin] = 1;
H.push(make_pair(g[vecin],vecin));
}
}
}
cout<<sol+1;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2680 KB |
Output is correct |
2 |
Correct |
4 ms |
2680 KB |
Output is correct |
3 |
Correct |
13 ms |
3320 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 |
3320 KB |
Output is correct |
7 |
Correct |
12 ms |
3292 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 |
2852 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2680 KB |
Output is correct |
2 |
Correct |
4 ms |
2680 KB |
Output is correct |
3 |
Correct |
13 ms |
3320 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 |
3320 KB |
Output is correct |
7 |
Correct |
12 ms |
3292 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 |
2852 KB |
Output is correct |
11 |
Correct |
13 ms |
3328 KB |
Output is correct |
12 |
Correct |
13 ms |
3320 KB |
Output is correct |
13 |
Correct |
4 ms |
2680 KB |
Output is correct |
14 |
Correct |
13 ms |
3320 KB |
Output is correct |
15 |
Correct |
4 ms |
2680 KB |
Output is correct |
16 |
Correct |
13 ms |
3192 KB |
Output is correct |
17 |
Correct |
4 ms |
2680 KB |
Output is correct |
18 |
Correct |
13 ms |
3248 KB |
Output is correct |
19 |
Correct |
6 ms |
2808 KB |
Output is correct |
20 |
Correct |
9 ms |
3064 KB |
Output is correct |
21 |
Correct |
9 ms |
3084 KB |
Output is correct |
22 |
Correct |
6 ms |
2808 KB |
Output is correct |
23 |
Correct |
15 ms |
3356 KB |
Output is correct |
24 |
Correct |
6 ms |
2808 KB |
Output is correct |
25 |
Correct |
15 ms |
3448 KB |
Output is correct |
26 |
Correct |
14 ms |
3320 KB |
Output is correct |
27 |
Correct |
13 ms |
3320 KB |
Output is correct |
28 |
Correct |
14 ms |
3320 KB |
Output is correct |
29 |
Correct |
12 ms |
3320 KB |
Output is correct |
30 |
Correct |
16 ms |
3448 KB |
Output is correct |
31 |
Correct |
15 ms |
3420 KB |
Output is correct |
32 |
Correct |
16 ms |
3448 KB |
Output is correct |
33 |
Correct |
15 ms |
3472 KB |
Output is correct |
34 |
Correct |
15 ms |
3392 KB |
Output is correct |
35 |
Correct |
9 ms |
3064 KB |
Output is correct |
36 |
Correct |
9 ms |
3068 KB |
Output is correct |
37 |
Correct |
9 ms |
3064 KB |
Output is correct |
38 |
Correct |
5 ms |
2908 KB |
Output is correct |
39 |
Correct |
7 ms |
2936 KB |
Output is correct |
40 |
Correct |
20 ms |
3832 KB |
Output is correct |
41 |
Correct |
7 ms |
2936 KB |
Output is correct |
42 |
Correct |
20 ms |
3780 KB |
Output is correct |
43 |
Correct |
20 ms |
3832 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
2808 KB |
Output is correct |
2 |
Correct |
4 ms |
2684 KB |
Output is correct |
3 |
Correct |
4 ms |
2652 KB |
Output is correct |
4 |
Correct |
4 ms |
2680 KB |
Output is correct |
5 |
Correct |
4 ms |
2684 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 |
2808 KB |
Output is correct |
11 |
Correct |
423 ms |
28016 KB |
Output is correct |
12 |
Correct |
4 ms |
2676 KB |
Output is correct |
13 |
Correct |
413 ms |
27888 KB |
Output is correct |
14 |
Correct |
4 ms |
2680 KB |
Output is correct |
15 |
Correct |
411 ms |
27848 KB |
Output is correct |
16 |
Correct |
411 ms |
28016 KB |
Output is correct |
17 |
Correct |
413 ms |
27912 KB |
Output is correct |
18 |
Correct |
421 ms |
27996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2680 KB |
Output is correct |
2 |
Correct |
4 ms |
2680 KB |
Output is correct |
3 |
Correct |
13 ms |
3320 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 |
3320 KB |
Output is correct |
7 |
Correct |
12 ms |
3292 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 |
2852 KB |
Output is correct |
11 |
Correct |
13 ms |
3328 KB |
Output is correct |
12 |
Correct |
13 ms |
3320 KB |
Output is correct |
13 |
Correct |
4 ms |
2680 KB |
Output is correct |
14 |
Correct |
13 ms |
3320 KB |
Output is correct |
15 |
Correct |
4 ms |
2680 KB |
Output is correct |
16 |
Correct |
13 ms |
3192 KB |
Output is correct |
17 |
Correct |
4 ms |
2680 KB |
Output is correct |
18 |
Correct |
13 ms |
3248 KB |
Output is correct |
19 |
Correct |
6 ms |
2808 KB |
Output is correct |
20 |
Correct |
9 ms |
3064 KB |
Output is correct |
21 |
Correct |
9 ms |
3084 KB |
Output is correct |
22 |
Correct |
6 ms |
2808 KB |
Output is correct |
23 |
Correct |
15 ms |
3356 KB |
Output is correct |
24 |
Correct |
6 ms |
2808 KB |
Output is correct |
25 |
Correct |
15 ms |
3448 KB |
Output is correct |
26 |
Correct |
14 ms |
3320 KB |
Output is correct |
27 |
Correct |
13 ms |
3320 KB |
Output is correct |
28 |
Correct |
14 ms |
3320 KB |
Output is correct |
29 |
Correct |
12 ms |
3320 KB |
Output is correct |
30 |
Correct |
16 ms |
3448 KB |
Output is correct |
31 |
Correct |
15 ms |
3420 KB |
Output is correct |
32 |
Correct |
16 ms |
3448 KB |
Output is correct |
33 |
Correct |
15 ms |
3472 KB |
Output is correct |
34 |
Correct |
15 ms |
3392 KB |
Output is correct |
35 |
Correct |
9 ms |
3064 KB |
Output is correct |
36 |
Correct |
9 ms |
3068 KB |
Output is correct |
37 |
Correct |
9 ms |
3064 KB |
Output is correct |
38 |
Correct |
5 ms |
2908 KB |
Output is correct |
39 |
Correct |
7 ms |
2936 KB |
Output is correct |
40 |
Correct |
20 ms |
3832 KB |
Output is correct |
41 |
Correct |
7 ms |
2936 KB |
Output is correct |
42 |
Correct |
20 ms |
3780 KB |
Output is correct |
43 |
Correct |
20 ms |
3832 KB |
Output is correct |
44 |
Correct |
60 ms |
4888 KB |
Output is correct |
45 |
Correct |
2 ms |
2680 KB |
Output is correct |
46 |
Correct |
20 ms |
3804 KB |
Output is correct |
47 |
Incorrect |
35 ms |
4856 KB |
Output isn't correct |
48 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2680 KB |
Output is correct |
2 |
Correct |
4 ms |
2680 KB |
Output is correct |
3 |
Correct |
13 ms |
3320 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 |
3320 KB |
Output is correct |
7 |
Correct |
12 ms |
3292 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 |
2852 KB |
Output is correct |
11 |
Correct |
13 ms |
3328 KB |
Output is correct |
12 |
Correct |
13 ms |
3320 KB |
Output is correct |
13 |
Correct |
4 ms |
2680 KB |
Output is correct |
14 |
Correct |
13 ms |
3320 KB |
Output is correct |
15 |
Correct |
4 ms |
2680 KB |
Output is correct |
16 |
Correct |
13 ms |
3192 KB |
Output is correct |
17 |
Correct |
4 ms |
2680 KB |
Output is correct |
18 |
Correct |
13 ms |
3248 KB |
Output is correct |
19 |
Correct |
6 ms |
2808 KB |
Output is correct |
20 |
Correct |
9 ms |
3064 KB |
Output is correct |
21 |
Correct |
9 ms |
3084 KB |
Output is correct |
22 |
Correct |
6 ms |
2808 KB |
Output is correct |
23 |
Correct |
15 ms |
3356 KB |
Output is correct |
24 |
Correct |
6 ms |
2808 KB |
Output is correct |
25 |
Correct |
15 ms |
3448 KB |
Output is correct |
26 |
Correct |
14 ms |
3320 KB |
Output is correct |
27 |
Correct |
13 ms |
3320 KB |
Output is correct |
28 |
Correct |
14 ms |
3320 KB |
Output is correct |
29 |
Correct |
12 ms |
3320 KB |
Output is correct |
30 |
Correct |
16 ms |
3448 KB |
Output is correct |
31 |
Correct |
15 ms |
3420 KB |
Output is correct |
32 |
Correct |
16 ms |
3448 KB |
Output is correct |
33 |
Correct |
15 ms |
3472 KB |
Output is correct |
34 |
Correct |
15 ms |
3392 KB |
Output is correct |
35 |
Correct |
9 ms |
3064 KB |
Output is correct |
36 |
Correct |
9 ms |
3068 KB |
Output is correct |
37 |
Correct |
9 ms |
3064 KB |
Output is correct |
38 |
Correct |
5 ms |
2908 KB |
Output is correct |
39 |
Correct |
7 ms |
2936 KB |
Output is correct |
40 |
Correct |
20 ms |
3832 KB |
Output is correct |
41 |
Correct |
7 ms |
2936 KB |
Output is correct |
42 |
Correct |
20 ms |
3780 KB |
Output is correct |
43 |
Correct |
20 ms |
3832 KB |
Output is correct |
44 |
Correct |
4 ms |
2680 KB |
Output is correct |
45 |
Incorrect |
282 ms |
19640 KB |
Output isn't correct |
46 |
Halted |
0 ms |
0 KB |
- |