Submission #134254

# Submission time Handle Problem Language Result Execution time Memory
134254 2019-07-22T09:53:30 Z Kastanda Political Development (BOI17_politicaldevelopment) C++11
100 / 100
536 ms 28964 KB
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int N = 50005, K = 10;
int n, k, Mx, M[K], dp[1 << K];
set < int > Adj[N];
int main()
{
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++)
	{
		int d, v;
		scanf("%d", &d);
		for (int j = 0; j < d; j++)
			scanf("%d", &v), Adj[i].insert(v);
	}
	set < pair < int , int > > A;
	for (int i = 0; i < n; i++)
		A.insert({(int)Adj[i].size(), i});
	while (1)
	{
		if (A.size() <= 1)
		{
			Mx = max(Mx, (int)A.size());
			break;
		}
		int v = A.begin()->second;
		A.erase(A.begin());
		vector < int > vec;
		for (int u : Adj[v])
		{
			vec.pb(u);
			A.erase({(int)Adj[u].size(), u});
			Adj[u].erase(v);
			A.insert({(int)Adj[u].size(), u});
		}
		Adj[v].clear();
		int d = (int)vec.size();
		for (int i = 0; i < d; i++)
		{
			M[i] = (1 << i);
			for (int j = 0; j < d; j++)
				if (Adj[vec[i]].count(vec[j]))
					M[i] |= (1 << j);
		}
		dp[0] = 1;
		for (int i = 1; i < (1 << d); i++)
		{
			int lb = __builtin_ctz(i); dp[i] = 0;
			if (dp[i ^ (1 << lb)] && ((M[lb] & i) == i))
				dp[i] = 1, Mx = max(Mx, __builtin_popcount(i) + 1);
		}
 
	}
 
	return !printf("%d\n", Mx);
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &k);
  ~~~~~^~~~~~~~~~~~~~~~
politicaldevelopment.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &d);
   ~~~~~^~~~~~~~~~
politicaldevelopment.cpp:15:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &v), Adj[i].insert(v);
    ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 11 ms 3448 KB Output is correct
4 Correct 10 ms 3448 KB Output is correct
5 Correct 10 ms 3448 KB Output is correct
6 Correct 11 ms 3448 KB Output is correct
7 Correct 11 ms 3448 KB Output is correct
8 Correct 5 ms 2936 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 5 ms 2936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 11 ms 3448 KB Output is correct
4 Correct 10 ms 3448 KB Output is correct
5 Correct 10 ms 3448 KB Output is correct
6 Correct 11 ms 3448 KB Output is correct
7 Correct 11 ms 3448 KB Output is correct
8 Correct 5 ms 2936 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 5 ms 2936 KB Output is correct
11 Correct 10 ms 3452 KB Output is correct
12 Correct 10 ms 3448 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 10 ms 3448 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 11 ms 3448 KB Output is correct
17 Correct 4 ms 2684 KB Output is correct
18 Correct 11 ms 3448 KB Output is correct
19 Correct 5 ms 2936 KB Output is correct
20 Correct 8 ms 3196 KB Output is correct
21 Correct 8 ms 3192 KB Output is correct
22 Correct 11 ms 2936 KB Output is correct
23 Correct 15 ms 3576 KB Output is correct
24 Correct 7 ms 2936 KB Output is correct
25 Correct 14 ms 3572 KB Output is correct
26 Correct 12 ms 3448 KB Output is correct
27 Correct 10 ms 3448 KB Output is correct
28 Correct 12 ms 3448 KB Output is correct
29 Correct 10 ms 3452 KB Output is correct
30 Correct 13 ms 3576 KB Output is correct
31 Correct 13 ms 3576 KB Output is correct
32 Correct 13 ms 3576 KB Output is correct
33 Correct 12 ms 3576 KB Output is correct
34 Correct 12 ms 3576 KB Output is correct
35 Correct 8 ms 3064 KB Output is correct
36 Correct 8 ms 3064 KB Output is correct
37 Correct 8 ms 3064 KB Output is correct
38 Correct 7 ms 2936 KB Output is correct
39 Correct 7 ms 3064 KB Output is correct
40 Correct 19 ms 4020 KB Output is correct
41 Correct 7 ms 2936 KB Output is correct
42 Correct 18 ms 3960 KB Output is correct
43 Correct 18 ms 3960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2940 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 2684 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 4 ms 2680 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
11 Correct 511 ms 28828 KB Output is correct
12 Correct 4 ms 2680 KB Output is correct
13 Correct 520 ms 28884 KB Output is correct
14 Correct 4 ms 2680 KB Output is correct
15 Correct 520 ms 28872 KB Output is correct
16 Correct 511 ms 28920 KB Output is correct
17 Correct 518 ms 28964 KB Output is correct
18 Correct 536 ms 28920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 11 ms 3448 KB Output is correct
4 Correct 10 ms 3448 KB Output is correct
5 Correct 10 ms 3448 KB Output is correct
6 Correct 11 ms 3448 KB Output is correct
7 Correct 11 ms 3448 KB Output is correct
8 Correct 5 ms 2936 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 5 ms 2936 KB Output is correct
11 Correct 10 ms 3452 KB Output is correct
12 Correct 10 ms 3448 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 10 ms 3448 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 11 ms 3448 KB Output is correct
17 Correct 4 ms 2684 KB Output is correct
18 Correct 11 ms 3448 KB Output is correct
19 Correct 5 ms 2936 KB Output is correct
20 Correct 8 ms 3196 KB Output is correct
21 Correct 8 ms 3192 KB Output is correct
22 Correct 11 ms 2936 KB Output is correct
23 Correct 15 ms 3576 KB Output is correct
24 Correct 7 ms 2936 KB Output is correct
25 Correct 14 ms 3572 KB Output is correct
26 Correct 12 ms 3448 KB Output is correct
27 Correct 10 ms 3448 KB Output is correct
28 Correct 12 ms 3448 KB Output is correct
29 Correct 10 ms 3452 KB Output is correct
30 Correct 13 ms 3576 KB Output is correct
31 Correct 13 ms 3576 KB Output is correct
32 Correct 13 ms 3576 KB Output is correct
33 Correct 12 ms 3576 KB Output is correct
34 Correct 12 ms 3576 KB Output is correct
35 Correct 8 ms 3064 KB Output is correct
36 Correct 8 ms 3064 KB Output is correct
37 Correct 8 ms 3064 KB Output is correct
38 Correct 7 ms 2936 KB Output is correct
39 Correct 7 ms 3064 KB Output is correct
40 Correct 19 ms 4020 KB Output is correct
41 Correct 7 ms 2936 KB Output is correct
42 Correct 18 ms 3960 KB Output is correct
43 Correct 18 ms 3960 KB Output is correct
44 Correct 28 ms 4984 KB Output is correct
45 Correct 5 ms 2680 KB Output is correct
46 Correct 18 ms 3960 KB Output is correct
47 Correct 34 ms 5016 KB Output is correct
48 Correct 18 ms 3960 KB Output is correct
49 Correct 35 ms 4984 KB Output is correct
50 Correct 33 ms 4984 KB Output is correct
51 Correct 76 ms 7032 KB Output is correct
52 Correct 11 ms 3448 KB Output is correct
53 Correct 69 ms 7544 KB Output is correct
54 Correct 95 ms 7544 KB Output is correct
55 Correct 11 ms 3448 KB Output is correct
56 Correct 10 ms 3448 KB Output is correct
57 Correct 5 ms 2936 KB Output is correct
58 Correct 70 ms 7624 KB Output is correct
59 Correct 15 ms 3960 KB Output is correct
60 Correct 11 ms 3448 KB Output is correct
61 Correct 14 ms 3960 KB Output is correct
62 Correct 14 ms 3960 KB Output is correct
63 Correct 28 ms 5084 KB Output is correct
64 Correct 24 ms 4728 KB Output is correct
65 Correct 16 ms 3832 KB Output is correct
66 Correct 15 ms 4024 KB Output is correct
67 Correct 40 ms 5368 KB Output is correct
68 Correct 24 ms 4728 KB Output is correct
69 Correct 16 ms 3960 KB Output is correct
70 Correct 31 ms 4856 KB Output is correct
71 Correct 39 ms 5368 KB Output is correct
72 Correct 38 ms 5240 KB Output is correct
73 Correct 10 ms 3452 KB Output is correct
74 Correct 31 ms 4728 KB Output is correct
75 Correct 40 ms 5240 KB Output is correct
76 Correct 24 ms 4344 KB Output is correct
77 Correct 100 ms 5880 KB Output is correct
78 Correct 11 ms 3452 KB Output is correct
79 Correct 28 ms 4216 KB Output is correct
80 Correct 23 ms 4216 KB Output is correct
81 Correct 52 ms 5912 KB Output is correct
82 Correct 7 ms 2936 KB Output is correct
83 Correct 25 ms 4216 KB Output is correct
84 Correct 38 ms 5240 KB Output is correct
85 Correct 7 ms 2936 KB Output is correct
86 Correct 37 ms 5244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 11 ms 3448 KB Output is correct
4 Correct 10 ms 3448 KB Output is correct
5 Correct 10 ms 3448 KB Output is correct
6 Correct 11 ms 3448 KB Output is correct
7 Correct 11 ms 3448 KB Output is correct
8 Correct 5 ms 2936 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 5 ms 2936 KB Output is correct
11 Correct 10 ms 3452 KB Output is correct
12 Correct 10 ms 3448 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 10 ms 3448 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 11 ms 3448 KB Output is correct
17 Correct 4 ms 2684 KB Output is correct
18 Correct 11 ms 3448 KB Output is correct
19 Correct 5 ms 2936 KB Output is correct
20 Correct 8 ms 3196 KB Output is correct
21 Correct 8 ms 3192 KB Output is correct
22 Correct 11 ms 2936 KB Output is correct
23 Correct 15 ms 3576 KB Output is correct
24 Correct 7 ms 2936 KB Output is correct
25 Correct 14 ms 3572 KB Output is correct
26 Correct 12 ms 3448 KB Output is correct
27 Correct 10 ms 3448 KB Output is correct
28 Correct 12 ms 3448 KB Output is correct
29 Correct 10 ms 3452 KB Output is correct
30 Correct 13 ms 3576 KB Output is correct
31 Correct 13 ms 3576 KB Output is correct
32 Correct 13 ms 3576 KB Output is correct
33 Correct 12 ms 3576 KB Output is correct
34 Correct 12 ms 3576 KB Output is correct
35 Correct 8 ms 3064 KB Output is correct
36 Correct 8 ms 3064 KB Output is correct
37 Correct 8 ms 3064 KB Output is correct
38 Correct 7 ms 2936 KB Output is correct
39 Correct 7 ms 3064 KB Output is correct
40 Correct 19 ms 4020 KB Output is correct
41 Correct 7 ms 2936 KB Output is correct
42 Correct 18 ms 3960 KB Output is correct
43 Correct 18 ms 3960 KB Output is correct
44 Correct 4 ms 2680 KB Output is correct
45 Correct 335 ms 20984 KB Output is correct
46 Correct 139 ms 13176 KB Output is correct
47 Correct 342 ms 20860 KB Output is correct
48 Correct 335 ms 20856 KB Output is correct
49 Correct 95 ms 10360 KB Output is correct
50 Correct 358 ms 26220 KB Output is correct
51 Correct 340 ms 20852 KB Output is correct
52 Correct 98 ms 10360 KB Output is correct
53 Correct 94 ms 10332 KB Output is correct
54 Correct 22 ms 5112 KB Output is correct
55 Correct 355 ms 26176 KB Output is correct
56 Correct 51 ms 7672 KB Output is correct
57 Correct 98 ms 10364 KB Output is correct
58 Correct 110 ms 13176 KB Output is correct
59 Correct 53 ms 7672 KB Output is correct
60 Correct 52 ms 7744 KB Output is correct
61 Correct 114 ms 13128 KB Output is correct
62 Correct 81 ms 10380 KB Output is correct
63 Correct 174 ms 14328 KB Output is correct
64 Correct 52 ms 7800 KB Output is correct
65 Correct 236 ms 17016 KB Output is correct
66 Correct 83 ms 10360 KB Output is correct
67 Correct 172 ms 14508 KB Output is correct
68 Correct 225 ms 16376 KB Output is correct
69 Correct 245 ms 16916 KB Output is correct
70 Correct 88 ms 10332 KB Output is correct
71 Correct 225 ms 16376 KB Output is correct
72 Correct 174 ms 14072 KB Output is correct
73 Correct 255 ms 18732 KB Output is correct
74 Correct 89 ms 10360 KB Output is correct
75 Correct 88 ms 8952 KB Output is correct
76 Correct 177 ms 13944 KB Output is correct
77 Correct 266 ms 18680 KB Output is correct
78 Correct 120 ms 10616 KB Output is correct
79 Correct 85 ms 8952 KB Output is correct
80 Correct 43 ms 5880 KB Output is correct
81 Correct 118 ms 10784 KB Output is correct
82 Correct 194 ms 15680 KB Output is correct
83 Correct 46 ms 5904 KB Output is correct
84 Correct 191 ms 15776 KB Output is correct