#include <bits/stdc++.h>
using namespace std;
struct pv {
int u, a;
bool operator < ( const pv &x ) const {
if ( a == x.a )
return u < x.u;
return a < x.a;
}
};
const int MAX_N = 5e4;
const int MAX_K = 10;
int perm[MAX_N], pos[MAX_N];
unordered_set<int> adj[MAX_N];
set<pv> vertMinSize;
int solve( vector<int> vertices ) {
int n = vertices.size();
for ( int i = 0; i < n; i++ )
pos[vertices[i]] = i;
int ans = 0;
for ( int mask = 0; mask < (1 << n); mask++ ) {
vector<int> v;
for ( int i = 0; i < n; i++ ) {
if ( (mask >> i) & 1)
v.push_back( vertices[i] );
}
bool ok = true;
for ( int x: v ) {
for ( int y: v ) {
if ( x != y && adj[x].find( y ) == adj[x].end() )
ok = false;
}
}
if ( ok )
ans = max( ans, (int)v.size() );
}
for ( int i = 0; i < n; i++ )
pos[vertices[i]] = -1;
return ans;
}
int main() {
int n, k, minn = n;
cin >> n >> k;
for ( int u = 0; u < n; u++ ) {
int d;
cin >> d;
for ( int j = 0; j < d; j++ ) {
int v;
cin >> v;
adj[u].insert( v );
}
minn = min( minn, d );
vertMinSize.insert( { u, d } );
}
for ( int i = 0; i < n; i++ )
pos[i] = -1;
if ( minn > k )
exit( 1 );
int ans = 0;
for ( int i = 0; i < n; i++ ) {
int u = vertMinSize.begin()->u;
vector<int> vertices;
vertices.push_back( u );
for ( int v: adj[u] )
vertices.push_back( v );
ans = max( ans, solve( vertices ) );
for ( int v: adj[u] ) {
vertMinSize.erase( { v, (int)adj[v].size() } );
adj[v].erase( u );
vertMinSize.insert( { v, (int)adj[v].size() } );
}
vertMinSize.erase( { u, (int)adj[u].size() } );
adj[u].clear();
}
cout << ans;
return 0;
}
Compilation message
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:53:15: warning: 'n' is used uninitialized in this function [-Wuninitialized]
53 | int n, k, minn = n;
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3160 KB |
Output is correct |
2 |
Correct |
1 ms |
3164 KB |
Output is correct |
3 |
Correct |
8 ms |
4208 KB |
Output is correct |
4 |
Correct |
7 ms |
4292 KB |
Output is correct |
5 |
Correct |
7 ms |
4188 KB |
Output is correct |
6 |
Correct |
8 ms |
4400 KB |
Output is correct |
7 |
Correct |
8 ms |
4412 KB |
Output is correct |
8 |
Correct |
3 ms |
3420 KB |
Output is correct |
9 |
Correct |
1 ms |
3164 KB |
Output is correct |
10 |
Correct |
3 ms |
3420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3160 KB |
Output is correct |
2 |
Correct |
1 ms |
3164 KB |
Output is correct |
3 |
Correct |
8 ms |
4208 KB |
Output is correct |
4 |
Correct |
7 ms |
4292 KB |
Output is correct |
5 |
Correct |
7 ms |
4188 KB |
Output is correct |
6 |
Correct |
8 ms |
4400 KB |
Output is correct |
7 |
Correct |
8 ms |
4412 KB |
Output is correct |
8 |
Correct |
3 ms |
3420 KB |
Output is correct |
9 |
Correct |
1 ms |
3164 KB |
Output is correct |
10 |
Correct |
3 ms |
3420 KB |
Output is correct |
11 |
Correct |
8 ms |
4188 KB |
Output is correct |
12 |
Correct |
7 ms |
4320 KB |
Output is correct |
13 |
Correct |
1 ms |
3164 KB |
Output is correct |
14 |
Correct |
7 ms |
4388 KB |
Output is correct |
15 |
Correct |
1 ms |
3164 KB |
Output is correct |
16 |
Correct |
8 ms |
4188 KB |
Output is correct |
17 |
Correct |
1 ms |
3180 KB |
Output is correct |
18 |
Correct |
8 ms |
4188 KB |
Output is correct |
19 |
Correct |
3 ms |
3388 KB |
Output is correct |
20 |
Correct |
5 ms |
3932 KB |
Output is correct |
21 |
Correct |
5 ms |
3932 KB |
Output is correct |
22 |
Correct |
4 ms |
3420 KB |
Output is correct |
23 |
Correct |
9 ms |
4184 KB |
Output is correct |
24 |
Correct |
3 ms |
3420 KB |
Output is correct |
25 |
Correct |
9 ms |
4444 KB |
Output is correct |
26 |
Correct |
9 ms |
4188 KB |
Output is correct |
27 |
Correct |
7 ms |
4188 KB |
Output is correct |
28 |
Correct |
9 ms |
4188 KB |
Output is correct |
29 |
Correct |
7 ms |
4188 KB |
Output is correct |
30 |
Correct |
9 ms |
4440 KB |
Output is correct |
31 |
Correct |
9 ms |
4444 KB |
Output is correct |
32 |
Correct |
9 ms |
4444 KB |
Output is correct |
33 |
Correct |
9 ms |
4476 KB |
Output is correct |
34 |
Correct |
10 ms |
4444 KB |
Output is correct |
35 |
Correct |
5 ms |
3676 KB |
Output is correct |
36 |
Correct |
5 ms |
3676 KB |
Output is correct |
37 |
Correct |
5 ms |
3676 KB |
Output is correct |
38 |
Correct |
4 ms |
3416 KB |
Output is correct |
39 |
Correct |
5 ms |
3932 KB |
Output is correct |
40 |
Correct |
14 ms |
4700 KB |
Output is correct |
41 |
Correct |
6 ms |
3420 KB |
Output is correct |
42 |
Correct |
17 ms |
4712 KB |
Output is correct |
43 |
Correct |
14 ms |
4700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
3420 KB |
Output is correct |
2 |
Correct |
1 ms |
3184 KB |
Output is correct |
3 |
Correct |
1 ms |
3052 KB |
Output is correct |
4 |
Correct |
1 ms |
3164 KB |
Output is correct |
5 |
Correct |
1 ms |
3188 KB |
Output is correct |
6 |
Correct |
1 ms |
3168 KB |
Output is correct |
7 |
Correct |
2 ms |
3180 KB |
Output is correct |
8 |
Correct |
1 ms |
3164 KB |
Output is correct |
9 |
Correct |
1 ms |
3164 KB |
Output is correct |
10 |
Correct |
1 ms |
3164 KB |
Output is correct |
11 |
Correct |
1338 ms |
26808 KB |
Output is correct |
12 |
Correct |
1 ms |
3164 KB |
Output is correct |
13 |
Correct |
1336 ms |
27916 KB |
Output is correct |
14 |
Correct |
1 ms |
3164 KB |
Output is correct |
15 |
Correct |
1338 ms |
27988 KB |
Output is correct |
16 |
Correct |
1359 ms |
27912 KB |
Output is correct |
17 |
Correct |
1331 ms |
27972 KB |
Output is correct |
18 |
Correct |
1348 ms |
27920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3160 KB |
Output is correct |
2 |
Correct |
1 ms |
3164 KB |
Output is correct |
3 |
Correct |
8 ms |
4208 KB |
Output is correct |
4 |
Correct |
7 ms |
4292 KB |
Output is correct |
5 |
Correct |
7 ms |
4188 KB |
Output is correct |
6 |
Correct |
8 ms |
4400 KB |
Output is correct |
7 |
Correct |
8 ms |
4412 KB |
Output is correct |
8 |
Correct |
3 ms |
3420 KB |
Output is correct |
9 |
Correct |
1 ms |
3164 KB |
Output is correct |
10 |
Correct |
3 ms |
3420 KB |
Output is correct |
11 |
Correct |
8 ms |
4188 KB |
Output is correct |
12 |
Correct |
7 ms |
4320 KB |
Output is correct |
13 |
Correct |
1 ms |
3164 KB |
Output is correct |
14 |
Correct |
7 ms |
4388 KB |
Output is correct |
15 |
Correct |
1 ms |
3164 KB |
Output is correct |
16 |
Correct |
8 ms |
4188 KB |
Output is correct |
17 |
Correct |
1 ms |
3180 KB |
Output is correct |
18 |
Correct |
8 ms |
4188 KB |
Output is correct |
19 |
Correct |
3 ms |
3388 KB |
Output is correct |
20 |
Correct |
5 ms |
3932 KB |
Output is correct |
21 |
Correct |
5 ms |
3932 KB |
Output is correct |
22 |
Correct |
4 ms |
3420 KB |
Output is correct |
23 |
Correct |
9 ms |
4184 KB |
Output is correct |
24 |
Correct |
3 ms |
3420 KB |
Output is correct |
25 |
Correct |
9 ms |
4444 KB |
Output is correct |
26 |
Correct |
9 ms |
4188 KB |
Output is correct |
27 |
Correct |
7 ms |
4188 KB |
Output is correct |
28 |
Correct |
9 ms |
4188 KB |
Output is correct |
29 |
Correct |
7 ms |
4188 KB |
Output is correct |
30 |
Correct |
9 ms |
4440 KB |
Output is correct |
31 |
Correct |
9 ms |
4444 KB |
Output is correct |
32 |
Correct |
9 ms |
4444 KB |
Output is correct |
33 |
Correct |
9 ms |
4476 KB |
Output is correct |
34 |
Correct |
10 ms |
4444 KB |
Output is correct |
35 |
Correct |
5 ms |
3676 KB |
Output is correct |
36 |
Correct |
5 ms |
3676 KB |
Output is correct |
37 |
Correct |
5 ms |
3676 KB |
Output is correct |
38 |
Correct |
4 ms |
3416 KB |
Output is correct |
39 |
Correct |
5 ms |
3932 KB |
Output is correct |
40 |
Correct |
14 ms |
4700 KB |
Output is correct |
41 |
Correct |
6 ms |
3420 KB |
Output is correct |
42 |
Correct |
17 ms |
4712 KB |
Output is correct |
43 |
Correct |
14 ms |
4700 KB |
Output is correct |
44 |
Correct |
145 ms |
5216 KB |
Output is correct |
45 |
Correct |
1 ms |
3164 KB |
Output is correct |
46 |
Correct |
15 ms |
4700 KB |
Output is correct |
47 |
Correct |
42 ms |
5468 KB |
Output is correct |
48 |
Correct |
14 ms |
4712 KB |
Output is correct |
49 |
Correct |
43 ms |
5476 KB |
Output is correct |
50 |
Correct |
47 ms |
5468 KB |
Output is correct |
51 |
Correct |
905 ms |
7256 KB |
Output is correct |
52 |
Correct |
7 ms |
4200 KB |
Output is correct |
53 |
Correct |
1181 ms |
7560 KB |
Output is correct |
54 |
Correct |
2087 ms |
7720 KB |
Output is correct |
55 |
Correct |
8 ms |
4188 KB |
Output is correct |
56 |
Correct |
7 ms |
4216 KB |
Output is correct |
57 |
Correct |
3 ms |
3420 KB |
Output is correct |
58 |
Correct |
1166 ms |
7560 KB |
Output is correct |
59 |
Correct |
15 ms |
4700 KB |
Output is correct |
60 |
Correct |
9 ms |
4188 KB |
Output is correct |
61 |
Correct |
19 ms |
4712 KB |
Output is correct |
62 |
Correct |
15 ms |
4700 KB |
Output is correct |
63 |
Correct |
142 ms |
5416 KB |
Output is correct |
64 |
Correct |
78 ms |
5232 KB |
Output is correct |
65 |
Correct |
12 ms |
4444 KB |
Output is correct |
66 |
Correct |
15 ms |
4504 KB |
Output is correct |
67 |
Correct |
143 ms |
5736 KB |
Output is correct |
68 |
Correct |
72 ms |
5228 KB |
Output is correct |
69 |
Correct |
13 ms |
4444 KB |
Output is correct |
70 |
Correct |
39 ms |
5232 KB |
Output is correct |
71 |
Correct |
142 ms |
5808 KB |
Output is correct |
72 |
Correct |
107 ms |
5724 KB |
Output is correct |
73 |
Correct |
7 ms |
4188 KB |
Output is correct |
74 |
Correct |
41 ms |
5220 KB |
Output is correct |
75 |
Correct |
104 ms |
5752 KB |
Output is correct |
76 |
Correct |
19 ms |
4956 KB |
Output is correct |
77 |
Correct |
343 ms |
6140 KB |
Output is correct |
78 |
Correct |
7 ms |
4188 KB |
Output is correct |
79 |
Correct |
162 ms |
4644 KB |
Output is correct |
80 |
Correct |
19 ms |
4956 KB |
Output is correct |
81 |
Correct |
338 ms |
6144 KB |
Output is correct |
82 |
Correct |
4 ms |
3420 KB |
Output is correct |
83 |
Correct |
166 ms |
4644 KB |
Output is correct |
84 |
Correct |
119 ms |
5468 KB |
Output is correct |
85 |
Correct |
4 ms |
3420 KB |
Output is correct |
86 |
Correct |
127 ms |
5580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3160 KB |
Output is correct |
2 |
Correct |
1 ms |
3164 KB |
Output is correct |
3 |
Correct |
8 ms |
4208 KB |
Output is correct |
4 |
Correct |
7 ms |
4292 KB |
Output is correct |
5 |
Correct |
7 ms |
4188 KB |
Output is correct |
6 |
Correct |
8 ms |
4400 KB |
Output is correct |
7 |
Correct |
8 ms |
4412 KB |
Output is correct |
8 |
Correct |
3 ms |
3420 KB |
Output is correct |
9 |
Correct |
1 ms |
3164 KB |
Output is correct |
10 |
Correct |
3 ms |
3420 KB |
Output is correct |
11 |
Correct |
8 ms |
4188 KB |
Output is correct |
12 |
Correct |
7 ms |
4320 KB |
Output is correct |
13 |
Correct |
1 ms |
3164 KB |
Output is correct |
14 |
Correct |
7 ms |
4388 KB |
Output is correct |
15 |
Correct |
1 ms |
3164 KB |
Output is correct |
16 |
Correct |
8 ms |
4188 KB |
Output is correct |
17 |
Correct |
1 ms |
3180 KB |
Output is correct |
18 |
Correct |
8 ms |
4188 KB |
Output is correct |
19 |
Correct |
3 ms |
3388 KB |
Output is correct |
20 |
Correct |
5 ms |
3932 KB |
Output is correct |
21 |
Correct |
5 ms |
3932 KB |
Output is correct |
22 |
Correct |
4 ms |
3420 KB |
Output is correct |
23 |
Correct |
9 ms |
4184 KB |
Output is correct |
24 |
Correct |
3 ms |
3420 KB |
Output is correct |
25 |
Correct |
9 ms |
4444 KB |
Output is correct |
26 |
Correct |
9 ms |
4188 KB |
Output is correct |
27 |
Correct |
7 ms |
4188 KB |
Output is correct |
28 |
Correct |
9 ms |
4188 KB |
Output is correct |
29 |
Correct |
7 ms |
4188 KB |
Output is correct |
30 |
Correct |
9 ms |
4440 KB |
Output is correct |
31 |
Correct |
9 ms |
4444 KB |
Output is correct |
32 |
Correct |
9 ms |
4444 KB |
Output is correct |
33 |
Correct |
9 ms |
4476 KB |
Output is correct |
34 |
Correct |
10 ms |
4444 KB |
Output is correct |
35 |
Correct |
5 ms |
3676 KB |
Output is correct |
36 |
Correct |
5 ms |
3676 KB |
Output is correct |
37 |
Correct |
5 ms |
3676 KB |
Output is correct |
38 |
Correct |
4 ms |
3416 KB |
Output is correct |
39 |
Correct |
5 ms |
3932 KB |
Output is correct |
40 |
Correct |
14 ms |
4700 KB |
Output is correct |
41 |
Correct |
6 ms |
3420 KB |
Output is correct |
42 |
Correct |
17 ms |
4712 KB |
Output is correct |
43 |
Correct |
14 ms |
4700 KB |
Output is correct |
44 |
Correct |
1 ms |
3160 KB |
Output is correct |
45 |
Correct |
293 ms |
22612 KB |
Output is correct |
46 |
Correct |
112 ms |
17068 KB |
Output is correct |
47 |
Correct |
307 ms |
22612 KB |
Output is correct |
48 |
Correct |
309 ms |
22636 KB |
Output is correct |
49 |
Correct |
88 ms |
15600 KB |
Output is correct |
50 |
Correct |
343 ms |
28512 KB |
Output is correct |
51 |
Correct |
308 ms |
22692 KB |
Output is correct |
52 |
Correct |
80 ms |
15188 KB |
Output is correct |
53 |
Correct |
73 ms |
15460 KB |
Output is correct |
54 |
Correct |
22 ms |
5724 KB |
Output is correct |
55 |
Correct |
337 ms |
29044 KB |
Output is correct |
56 |
Correct |
55 ms |
13140 KB |
Output is correct |
57 |
Correct |
90 ms |
15164 KB |
Output is correct |
58 |
Correct |
114 ms |
16828 KB |
Output is correct |
59 |
Correct |
51 ms |
13128 KB |
Output is correct |
60 |
Correct |
58 ms |
12884 KB |
Output is correct |
61 |
Correct |
112 ms |
16724 KB |
Output is correct |
62 |
Correct |
80 ms |
14932 KB |
Output is correct |
63 |
Correct |
155 ms |
17516 KB |
Output is correct |
64 |
Correct |
52 ms |
12964 KB |
Output is correct |
65 |
Correct |
208 ms |
19592 KB |
Output is correct |
66 |
Correct |
75 ms |
14932 KB |
Output is correct |
67 |
Correct |
152 ms |
17740 KB |
Output is correct |
68 |
Correct |
209 ms |
19368 KB |
Output is correct |
69 |
Correct |
214 ms |
19596 KB |
Output is correct |
70 |
Correct |
80 ms |
14932 KB |
Output is correct |
71 |
Correct |
195 ms |
19148 KB |
Output is correct |
72 |
Correct |
136 ms |
17868 KB |
Output is correct |
73 |
Correct |
243 ms |
20564 KB |
Output is correct |
74 |
Correct |
80 ms |
14864 KB |
Output is correct |
75 |
Correct |
75 ms |
10588 KB |
Output is correct |
76 |
Correct |
130 ms |
17748 KB |
Output is correct |
77 |
Correct |
257 ms |
20712 KB |
Output is correct |
78 |
Correct |
104 ms |
11944 KB |
Output is correct |
79 |
Correct |
71 ms |
10576 KB |
Output is correct |
80 |
Correct |
33 ms |
7000 KB |
Output is correct |
81 |
Correct |
107 ms |
11940 KB |
Output is correct |
82 |
Correct |
198 ms |
18772 KB |
Output is correct |
83 |
Correct |
40 ms |
7004 KB |
Output is correct |
84 |
Correct |
176 ms |
18676 KB |
Output is correct |