#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]){
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));
}
}
L[nod].clear();
}
cout<<sol+1;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 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 |
14 ms |
3320 KB |
Output is correct |
5 |
Correct |
14 ms |
3320 KB |
Output is correct |
6 |
Correct |
14 ms |
3320 KB |
Output is correct |
7 |
Correct |
13 ms |
3320 KB |
Output is correct |
8 |
Correct |
10 ms |
2812 KB |
Output is correct |
9 |
Correct |
5 ms |
2680 KB |
Output is correct |
10 |
Correct |
7 ms |
2808 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 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 |
14 ms |
3320 KB |
Output is correct |
5 |
Correct |
14 ms |
3320 KB |
Output is correct |
6 |
Correct |
14 ms |
3320 KB |
Output is correct |
7 |
Correct |
13 ms |
3320 KB |
Output is correct |
8 |
Correct |
10 ms |
2812 KB |
Output is correct |
9 |
Correct |
5 ms |
2680 KB |
Output is correct |
10 |
Correct |
7 ms |
2808 KB |
Output is correct |
11 |
Correct |
16 ms |
3320 KB |
Output is correct |
12 |
Correct |
14 ms |
3320 KB |
Output is correct |
13 |
Correct |
5 ms |
2680 KB |
Output is correct |
14 |
Correct |
14 ms |
3268 KB |
Output is correct |
15 |
Correct |
5 ms |
2680 KB |
Output is correct |
16 |
Correct |
13 ms |
3320 KB |
Output is correct |
17 |
Correct |
4 ms |
2680 KB |
Output is correct |
18 |
Correct |
13 ms |
3292 KB |
Output is correct |
19 |
Correct |
6 ms |
2808 KB |
Output is correct |
20 |
Correct |
9 ms |
3064 KB |
Output is correct |
21 |
Correct |
10 ms |
2980 KB |
Output is correct |
22 |
Correct |
6 ms |
2808 KB |
Output is correct |
23 |
Correct |
15 ms |
3448 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 |
3324 KB |
Output is correct |
27 |
Correct |
12 ms |
3324 KB |
Output is correct |
28 |
Correct |
16 ms |
3320 KB |
Output is correct |
29 |
Correct |
14 ms |
3320 KB |
Output is correct |
30 |
Correct |
16 ms |
3532 KB |
Output is correct |
31 |
Correct |
16 ms |
3448 KB |
Output is correct |
32 |
Correct |
17 ms |
3576 KB |
Output is correct |
33 |
Correct |
17 ms |
3448 KB |
Output is correct |
34 |
Correct |
17 ms |
3448 KB |
Output is correct |
35 |
Correct |
10 ms |
3064 KB |
Output is correct |
36 |
Correct |
10 ms |
3064 KB |
Output is correct |
37 |
Correct |
9 ms |
3068 KB |
Output is correct |
38 |
Correct |
8 ms |
2936 KB |
Output is correct |
39 |
Correct |
8 ms |
3064 KB |
Output is correct |
40 |
Correct |
23 ms |
3832 KB |
Output is correct |
41 |
Correct |
9 ms |
3064 KB |
Output is correct |
42 |
Correct |
22 ms |
3800 KB |
Output is correct |
43 |
Correct |
23 ms |
3832 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
2780 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 |
5 ms |
2808 KB |
Output is correct |
9 |
Correct |
4 ms |
2680 KB |
Output is correct |
10 |
Correct |
5 ms |
2680 KB |
Output is correct |
11 |
Correct |
425 ms |
25412 KB |
Output is correct |
12 |
Correct |
4 ms |
2680 KB |
Output is correct |
13 |
Correct |
421 ms |
25580 KB |
Output is correct |
14 |
Correct |
5 ms |
2680 KB |
Output is correct |
15 |
Correct |
425 ms |
25336 KB |
Output is correct |
16 |
Correct |
423 ms |
25448 KB |
Output is correct |
17 |
Correct |
424 ms |
25420 KB |
Output is correct |
18 |
Correct |
422 ms |
25456 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 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 |
14 ms |
3320 KB |
Output is correct |
5 |
Correct |
14 ms |
3320 KB |
Output is correct |
6 |
Correct |
14 ms |
3320 KB |
Output is correct |
7 |
Correct |
13 ms |
3320 KB |
Output is correct |
8 |
Correct |
10 ms |
2812 KB |
Output is correct |
9 |
Correct |
5 ms |
2680 KB |
Output is correct |
10 |
Correct |
7 ms |
2808 KB |
Output is correct |
11 |
Correct |
16 ms |
3320 KB |
Output is correct |
12 |
Correct |
14 ms |
3320 KB |
Output is correct |
13 |
Correct |
5 ms |
2680 KB |
Output is correct |
14 |
Correct |
14 ms |
3268 KB |
Output is correct |
15 |
Correct |
5 ms |
2680 KB |
Output is correct |
16 |
Correct |
13 ms |
3320 KB |
Output is correct |
17 |
Correct |
4 ms |
2680 KB |
Output is correct |
18 |
Correct |
13 ms |
3292 KB |
Output is correct |
19 |
Correct |
6 ms |
2808 KB |
Output is correct |
20 |
Correct |
9 ms |
3064 KB |
Output is correct |
21 |
Correct |
10 ms |
2980 KB |
Output is correct |
22 |
Correct |
6 ms |
2808 KB |
Output is correct |
23 |
Correct |
15 ms |
3448 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 |
3324 KB |
Output is correct |
27 |
Correct |
12 ms |
3324 KB |
Output is correct |
28 |
Correct |
16 ms |
3320 KB |
Output is correct |
29 |
Correct |
14 ms |
3320 KB |
Output is correct |
30 |
Correct |
16 ms |
3532 KB |
Output is correct |
31 |
Correct |
16 ms |
3448 KB |
Output is correct |
32 |
Correct |
17 ms |
3576 KB |
Output is correct |
33 |
Correct |
17 ms |
3448 KB |
Output is correct |
34 |
Correct |
17 ms |
3448 KB |
Output is correct |
35 |
Correct |
10 ms |
3064 KB |
Output is correct |
36 |
Correct |
10 ms |
3064 KB |
Output is correct |
37 |
Correct |
9 ms |
3068 KB |
Output is correct |
38 |
Correct |
8 ms |
2936 KB |
Output is correct |
39 |
Correct |
8 ms |
3064 KB |
Output is correct |
40 |
Correct |
23 ms |
3832 KB |
Output is correct |
41 |
Correct |
9 ms |
3064 KB |
Output is correct |
42 |
Correct |
22 ms |
3800 KB |
Output is correct |
43 |
Correct |
23 ms |
3832 KB |
Output is correct |
44 |
Correct |
61 ms |
4728 KB |
Output is correct |
45 |
Correct |
3 ms |
2680 KB |
Output is correct |
46 |
Correct |
21 ms |
3832 KB |
Output is correct |
47 |
Incorrect |
35 ms |
4856 KB |
Output isn't correct |
48 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 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 |
14 ms |
3320 KB |
Output is correct |
5 |
Correct |
14 ms |
3320 KB |
Output is correct |
6 |
Correct |
14 ms |
3320 KB |
Output is correct |
7 |
Correct |
13 ms |
3320 KB |
Output is correct |
8 |
Correct |
10 ms |
2812 KB |
Output is correct |
9 |
Correct |
5 ms |
2680 KB |
Output is correct |
10 |
Correct |
7 ms |
2808 KB |
Output is correct |
11 |
Correct |
16 ms |
3320 KB |
Output is correct |
12 |
Correct |
14 ms |
3320 KB |
Output is correct |
13 |
Correct |
5 ms |
2680 KB |
Output is correct |
14 |
Correct |
14 ms |
3268 KB |
Output is correct |
15 |
Correct |
5 ms |
2680 KB |
Output is correct |
16 |
Correct |
13 ms |
3320 KB |
Output is correct |
17 |
Correct |
4 ms |
2680 KB |
Output is correct |
18 |
Correct |
13 ms |
3292 KB |
Output is correct |
19 |
Correct |
6 ms |
2808 KB |
Output is correct |
20 |
Correct |
9 ms |
3064 KB |
Output is correct |
21 |
Correct |
10 ms |
2980 KB |
Output is correct |
22 |
Correct |
6 ms |
2808 KB |
Output is correct |
23 |
Correct |
15 ms |
3448 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 |
3324 KB |
Output is correct |
27 |
Correct |
12 ms |
3324 KB |
Output is correct |
28 |
Correct |
16 ms |
3320 KB |
Output is correct |
29 |
Correct |
14 ms |
3320 KB |
Output is correct |
30 |
Correct |
16 ms |
3532 KB |
Output is correct |
31 |
Correct |
16 ms |
3448 KB |
Output is correct |
32 |
Correct |
17 ms |
3576 KB |
Output is correct |
33 |
Correct |
17 ms |
3448 KB |
Output is correct |
34 |
Correct |
17 ms |
3448 KB |
Output is correct |
35 |
Correct |
10 ms |
3064 KB |
Output is correct |
36 |
Correct |
10 ms |
3064 KB |
Output is correct |
37 |
Correct |
9 ms |
3068 KB |
Output is correct |
38 |
Correct |
8 ms |
2936 KB |
Output is correct |
39 |
Correct |
8 ms |
3064 KB |
Output is correct |
40 |
Correct |
23 ms |
3832 KB |
Output is correct |
41 |
Correct |
9 ms |
3064 KB |
Output is correct |
42 |
Correct |
22 ms |
3800 KB |
Output is correct |
43 |
Correct |
23 ms |
3832 KB |
Output is correct |
44 |
Correct |
4 ms |
2680 KB |
Output is correct |
45 |
Incorrect |
294 ms |
17776 KB |
Output isn't correct |
46 |
Halted |
0 ms |
0 KB |
- |