#include <bits/stdc++.h>
using namespace std;
#define int unsigned short
int32_t main(){
int n, k, d, a;
cin >> n >> k;
vector<vector<bool>> ady(n,vector<bool>(n,0));
set<set<int>> last;
vector<int> deg(n,0);
for(int i=0;i<n;i++){
last.insert({i});
cin >> d;
deg[i] = d;
for(int j=0;j<d;j++){
cin >> a;
ady[min(i,a)][max(i,a)] = 1;
}
}
int cur = 2;
bool optim = false;
while(cur<=k){
set<set<int>> nw;
for(auto li:last){
if(optim) break;
// last[i] --> completed graphs of cur-1 nodes
for(int x=0;x<n;x++){
if(deg[x]<cur-1) continue;
if (optim) break;
bool found = true;
for(auto p:li){
if(ady[min(x,p)][max(x,p)]==0){
found = false;
break;
}
}
if(found){
set<int> temp = li;
temp.insert(x);
nw.insert(temp);
//for(int kk=0;kk<last[i].size();kk++) cout << last[i][kk] << " ";
//cout << x << endl;
if(cur==k) optim = true;
}
}
}
if(nw.size()==0) break;
else{
last = nw;
cur++;
}
}
cout << cur-1 << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
5 ms |
4444 KB |
Output is correct |
4 |
Correct |
6 ms |
4440 KB |
Output is correct |
5 |
Correct |
6 ms |
4444 KB |
Output is correct |
6 |
Correct |
5 ms |
4444 KB |
Output is correct |
7 |
Correct |
5 ms |
4444 KB |
Output is correct |
8 |
Correct |
65 ms |
4444 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
6 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
5 ms |
4444 KB |
Output is correct |
4 |
Correct |
6 ms |
4440 KB |
Output is correct |
5 |
Correct |
6 ms |
4444 KB |
Output is correct |
6 |
Correct |
5 ms |
4444 KB |
Output is correct |
7 |
Correct |
5 ms |
4444 KB |
Output is correct |
8 |
Correct |
65 ms |
4444 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
6 ms |
4444 KB |
Output is correct |
11 |
Correct |
5 ms |
4444 KB |
Output is correct |
12 |
Correct |
142 ms |
5640 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
142 ms |
5632 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
152 ms |
5640 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
154 ms |
5460 KB |
Output is correct |
19 |
Correct |
66 ms |
4448 KB |
Output is correct |
20 |
Correct |
98 ms |
5048 KB |
Output is correct |
21 |
Correct |
87 ms |
4876 KB |
Output is correct |
22 |
Correct |
67 ms |
4468 KB |
Output is correct |
23 |
Correct |
91 ms |
5944 KB |
Output is correct |
24 |
Correct |
67 ms |
4452 KB |
Output is correct |
25 |
Correct |
125 ms |
6124 KB |
Output is correct |
26 |
Correct |
170 ms |
5740 KB |
Output is correct |
27 |
Correct |
167 ms |
5396 KB |
Output is correct |
28 |
Correct |
169 ms |
5696 KB |
Output is correct |
29 |
Correct |
151 ms |
5472 KB |
Output is correct |
30 |
Correct |
186 ms |
6228 KB |
Output is correct |
31 |
Correct |
184 ms |
6120 KB |
Output is correct |
32 |
Correct |
196 ms |
6216 KB |
Output is correct |
33 |
Correct |
179 ms |
6236 KB |
Output is correct |
34 |
Correct |
178 ms |
6000 KB |
Output is correct |
35 |
Correct |
47 ms |
2500 KB |
Output is correct |
36 |
Correct |
44 ms |
2600 KB |
Output is correct |
37 |
Correct |
46 ms |
2516 KB |
Output is correct |
38 |
Correct |
16 ms |
1572 KB |
Output is correct |
39 |
Correct |
15 ms |
1372 KB |
Output is correct |
40 |
Correct |
109 ms |
7464 KB |
Output is correct |
41 |
Correct |
20 ms |
1556 KB |
Output is correct |
42 |
Correct |
107 ms |
7508 KB |
Output is correct |
43 |
Correct |
96 ms |
7508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
4468 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Execution timed out |
3110 ms |
338488 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
5 ms |
4444 KB |
Output is correct |
4 |
Correct |
6 ms |
4440 KB |
Output is correct |
5 |
Correct |
6 ms |
4444 KB |
Output is correct |
6 |
Correct |
5 ms |
4444 KB |
Output is correct |
7 |
Correct |
5 ms |
4444 KB |
Output is correct |
8 |
Correct |
65 ms |
4444 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
6 ms |
4444 KB |
Output is correct |
11 |
Correct |
5 ms |
4444 KB |
Output is correct |
12 |
Correct |
142 ms |
5640 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
142 ms |
5632 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
152 ms |
5640 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
154 ms |
5460 KB |
Output is correct |
19 |
Correct |
66 ms |
4448 KB |
Output is correct |
20 |
Correct |
98 ms |
5048 KB |
Output is correct |
21 |
Correct |
87 ms |
4876 KB |
Output is correct |
22 |
Correct |
67 ms |
4468 KB |
Output is correct |
23 |
Correct |
91 ms |
5944 KB |
Output is correct |
24 |
Correct |
67 ms |
4452 KB |
Output is correct |
25 |
Correct |
125 ms |
6124 KB |
Output is correct |
26 |
Correct |
170 ms |
5740 KB |
Output is correct |
27 |
Correct |
167 ms |
5396 KB |
Output is correct |
28 |
Correct |
169 ms |
5696 KB |
Output is correct |
29 |
Correct |
151 ms |
5472 KB |
Output is correct |
30 |
Correct |
186 ms |
6228 KB |
Output is correct |
31 |
Correct |
184 ms |
6120 KB |
Output is correct |
32 |
Correct |
196 ms |
6216 KB |
Output is correct |
33 |
Correct |
179 ms |
6236 KB |
Output is correct |
34 |
Correct |
178 ms |
6000 KB |
Output is correct |
35 |
Correct |
47 ms |
2500 KB |
Output is correct |
36 |
Correct |
44 ms |
2600 KB |
Output is correct |
37 |
Correct |
46 ms |
2516 KB |
Output is correct |
38 |
Correct |
16 ms |
1572 KB |
Output is correct |
39 |
Correct |
15 ms |
1372 KB |
Output is correct |
40 |
Correct |
109 ms |
7464 KB |
Output is correct |
41 |
Correct |
20 ms |
1556 KB |
Output is correct |
42 |
Correct |
107 ms |
7508 KB |
Output is correct |
43 |
Correct |
96 ms |
7508 KB |
Output is correct |
44 |
Execution timed out |
3086 ms |
49576 KB |
Time limit exceeded |
45 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
5 ms |
4444 KB |
Output is correct |
4 |
Correct |
6 ms |
4440 KB |
Output is correct |
5 |
Correct |
6 ms |
4444 KB |
Output is correct |
6 |
Correct |
5 ms |
4444 KB |
Output is correct |
7 |
Correct |
5 ms |
4444 KB |
Output is correct |
8 |
Correct |
65 ms |
4444 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
6 ms |
4444 KB |
Output is correct |
11 |
Correct |
5 ms |
4444 KB |
Output is correct |
12 |
Correct |
142 ms |
5640 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
142 ms |
5632 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
152 ms |
5640 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
154 ms |
5460 KB |
Output is correct |
19 |
Correct |
66 ms |
4448 KB |
Output is correct |
20 |
Correct |
98 ms |
5048 KB |
Output is correct |
21 |
Correct |
87 ms |
4876 KB |
Output is correct |
22 |
Correct |
67 ms |
4468 KB |
Output is correct |
23 |
Correct |
91 ms |
5944 KB |
Output is correct |
24 |
Correct |
67 ms |
4452 KB |
Output is correct |
25 |
Correct |
125 ms |
6124 KB |
Output is correct |
26 |
Correct |
170 ms |
5740 KB |
Output is correct |
27 |
Correct |
167 ms |
5396 KB |
Output is correct |
28 |
Correct |
169 ms |
5696 KB |
Output is correct |
29 |
Correct |
151 ms |
5472 KB |
Output is correct |
30 |
Correct |
186 ms |
6228 KB |
Output is correct |
31 |
Correct |
184 ms |
6120 KB |
Output is correct |
32 |
Correct |
196 ms |
6216 KB |
Output is correct |
33 |
Correct |
179 ms |
6236 KB |
Output is correct |
34 |
Correct |
178 ms |
6000 KB |
Output is correct |
35 |
Correct |
47 ms |
2500 KB |
Output is correct |
36 |
Correct |
44 ms |
2600 KB |
Output is correct |
37 |
Correct |
46 ms |
2516 KB |
Output is correct |
38 |
Correct |
16 ms |
1572 KB |
Output is correct |
39 |
Correct |
15 ms |
1372 KB |
Output is correct |
40 |
Correct |
109 ms |
7464 KB |
Output is correct |
41 |
Correct |
20 ms |
1556 KB |
Output is correct |
42 |
Correct |
107 ms |
7508 KB |
Output is correct |
43 |
Correct |
96 ms |
7508 KB |
Output is correct |
44 |
Correct |
0 ms |
348 KB |
Output is correct |
45 |
Execution timed out |
3092 ms |
331616 KB |
Time limit exceeded |
46 |
Halted |
0 ms |
0 KB |
- |