#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;
for(int i=0;i<n;i++){
last.insert({i});
cin >> 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){
int s = last.size();
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 (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;
}
Compilation message
politicaldevelopment.cpp: In function 'int32_t main()':
politicaldevelopment.cpp:21:13: warning: unused variable 's' [-Wunused-variable]
21 | int s = last.size();
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
5 ms |
4440 KB |
Output is correct |
5 |
Correct |
5 ms |
4344 KB |
Output is correct |
6 |
Correct |
6 ms |
4444 KB |
Output is correct |
7 |
Correct |
5 ms |
4440 KB |
Output is correct |
8 |
Correct |
70 ms |
4456 KB |
Output is correct |
9 |
Correct |
0 ms |
600 KB |
Output is correct |
10 |
Correct |
7 ms |
4440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
5 ms |
4440 KB |
Output is correct |
5 |
Correct |
5 ms |
4344 KB |
Output is correct |
6 |
Correct |
6 ms |
4444 KB |
Output is correct |
7 |
Correct |
5 ms |
4440 KB |
Output is correct |
8 |
Correct |
70 ms |
4456 KB |
Output is correct |
9 |
Correct |
0 ms |
600 KB |
Output is correct |
10 |
Correct |
7 ms |
4440 KB |
Output is correct |
11 |
Correct |
5 ms |
4452 KB |
Output is correct |
12 |
Correct |
186 ms |
5456 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
165 ms |
5548 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
145 ms |
5392 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
150 ms |
5592 KB |
Output is correct |
19 |
Correct |
70 ms |
4444 KB |
Output is correct |
20 |
Correct |
95 ms |
4904 KB |
Output is correct |
21 |
Correct |
77 ms |
4840 KB |
Output is correct |
22 |
Correct |
71 ms |
4444 KB |
Output is correct |
23 |
Correct |
93 ms |
5936 KB |
Output is correct |
24 |
Correct |
71 ms |
4452 KB |
Output is correct |
25 |
Correct |
116 ms |
6080 KB |
Output is correct |
26 |
Correct |
157 ms |
5880 KB |
Output is correct |
27 |
Correct |
142 ms |
5460 KB |
Output is correct |
28 |
Correct |
165 ms |
5636 KB |
Output is correct |
29 |
Correct |
141 ms |
5460 KB |
Output is correct |
30 |
Correct |
184 ms |
6220 KB |
Output is correct |
31 |
Correct |
174 ms |
6240 KB |
Output is correct |
32 |
Correct |
186 ms |
6244 KB |
Output is correct |
33 |
Correct |
185 ms |
6548 KB |
Output is correct |
34 |
Correct |
162 ms |
6028 KB |
Output is correct |
35 |
Correct |
43 ms |
2484 KB |
Output is correct |
36 |
Correct |
43 ms |
2396 KB |
Output is correct |
37 |
Correct |
43 ms |
2396 KB |
Output is correct |
38 |
Correct |
15 ms |
1428 KB |
Output is correct |
39 |
Correct |
15 ms |
1372 KB |
Output is correct |
40 |
Correct |
87 ms |
7496 KB |
Output is correct |
41 |
Correct |
15 ms |
1568 KB |
Output is correct |
42 |
Correct |
84 ms |
7428 KB |
Output is correct |
43 |
Correct |
86 ms |
7504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
75 ms |
4448 KB |
Output is correct |
2 |
Correct |
1 ms |
604 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 |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 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 |
3088 ms |
340344 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
5 ms |
4440 KB |
Output is correct |
5 |
Correct |
5 ms |
4344 KB |
Output is correct |
6 |
Correct |
6 ms |
4444 KB |
Output is correct |
7 |
Correct |
5 ms |
4440 KB |
Output is correct |
8 |
Correct |
70 ms |
4456 KB |
Output is correct |
9 |
Correct |
0 ms |
600 KB |
Output is correct |
10 |
Correct |
7 ms |
4440 KB |
Output is correct |
11 |
Correct |
5 ms |
4452 KB |
Output is correct |
12 |
Correct |
186 ms |
5456 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
165 ms |
5548 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
145 ms |
5392 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
150 ms |
5592 KB |
Output is correct |
19 |
Correct |
70 ms |
4444 KB |
Output is correct |
20 |
Correct |
95 ms |
4904 KB |
Output is correct |
21 |
Correct |
77 ms |
4840 KB |
Output is correct |
22 |
Correct |
71 ms |
4444 KB |
Output is correct |
23 |
Correct |
93 ms |
5936 KB |
Output is correct |
24 |
Correct |
71 ms |
4452 KB |
Output is correct |
25 |
Correct |
116 ms |
6080 KB |
Output is correct |
26 |
Correct |
157 ms |
5880 KB |
Output is correct |
27 |
Correct |
142 ms |
5460 KB |
Output is correct |
28 |
Correct |
165 ms |
5636 KB |
Output is correct |
29 |
Correct |
141 ms |
5460 KB |
Output is correct |
30 |
Correct |
184 ms |
6220 KB |
Output is correct |
31 |
Correct |
174 ms |
6240 KB |
Output is correct |
32 |
Correct |
186 ms |
6244 KB |
Output is correct |
33 |
Correct |
185 ms |
6548 KB |
Output is correct |
34 |
Correct |
162 ms |
6028 KB |
Output is correct |
35 |
Correct |
43 ms |
2484 KB |
Output is correct |
36 |
Correct |
43 ms |
2396 KB |
Output is correct |
37 |
Correct |
43 ms |
2396 KB |
Output is correct |
38 |
Correct |
15 ms |
1428 KB |
Output is correct |
39 |
Correct |
15 ms |
1372 KB |
Output is correct |
40 |
Correct |
87 ms |
7496 KB |
Output is correct |
41 |
Correct |
15 ms |
1568 KB |
Output is correct |
42 |
Correct |
84 ms |
7428 KB |
Output is correct |
43 |
Correct |
86 ms |
7504 KB |
Output is correct |
44 |
Execution timed out |
3014 ms |
49652 KB |
Time limit exceeded |
45 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
5 ms |
4440 KB |
Output is correct |
5 |
Correct |
5 ms |
4344 KB |
Output is correct |
6 |
Correct |
6 ms |
4444 KB |
Output is correct |
7 |
Correct |
5 ms |
4440 KB |
Output is correct |
8 |
Correct |
70 ms |
4456 KB |
Output is correct |
9 |
Correct |
0 ms |
600 KB |
Output is correct |
10 |
Correct |
7 ms |
4440 KB |
Output is correct |
11 |
Correct |
5 ms |
4452 KB |
Output is correct |
12 |
Correct |
186 ms |
5456 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
165 ms |
5548 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
145 ms |
5392 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
150 ms |
5592 KB |
Output is correct |
19 |
Correct |
70 ms |
4444 KB |
Output is correct |
20 |
Correct |
95 ms |
4904 KB |
Output is correct |
21 |
Correct |
77 ms |
4840 KB |
Output is correct |
22 |
Correct |
71 ms |
4444 KB |
Output is correct |
23 |
Correct |
93 ms |
5936 KB |
Output is correct |
24 |
Correct |
71 ms |
4452 KB |
Output is correct |
25 |
Correct |
116 ms |
6080 KB |
Output is correct |
26 |
Correct |
157 ms |
5880 KB |
Output is correct |
27 |
Correct |
142 ms |
5460 KB |
Output is correct |
28 |
Correct |
165 ms |
5636 KB |
Output is correct |
29 |
Correct |
141 ms |
5460 KB |
Output is correct |
30 |
Correct |
184 ms |
6220 KB |
Output is correct |
31 |
Correct |
174 ms |
6240 KB |
Output is correct |
32 |
Correct |
186 ms |
6244 KB |
Output is correct |
33 |
Correct |
185 ms |
6548 KB |
Output is correct |
34 |
Correct |
162 ms |
6028 KB |
Output is correct |
35 |
Correct |
43 ms |
2484 KB |
Output is correct |
36 |
Correct |
43 ms |
2396 KB |
Output is correct |
37 |
Correct |
43 ms |
2396 KB |
Output is correct |
38 |
Correct |
15 ms |
1428 KB |
Output is correct |
39 |
Correct |
15 ms |
1372 KB |
Output is correct |
40 |
Correct |
87 ms |
7496 KB |
Output is correct |
41 |
Correct |
15 ms |
1568 KB |
Output is correct |
42 |
Correct |
84 ms |
7428 KB |
Output is correct |
43 |
Correct |
86 ms |
7504 KB |
Output is correct |
44 |
Correct |
0 ms |
348 KB |
Output is correct |
45 |
Execution timed out |
3070 ms |
333192 KB |
Time limit exceeded |
46 |
Halted |
0 ms |
0 KB |
- |