Submission #136808

# Submission time Handle Problem Language Result Execution time Memory
136808 2019-07-26T10:06:49 Z kdh9949 Political Development (BOI17_politicaldevelopment) C++17
100 / 100
528 ms 20472 KB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;

int n, k, d[50010], chk[50010], pro[50010], vs, a[11][11], ans;
set<pii> ss;
vector<int> e[50010], v, cv;
queue<int> q;

int btk(int t){
	if(t == vs) return cv.size();
	int ret = btk(t + 1);
	if(!cv.empty()) for(auto &j : cv) if(!a[j][t]) return ret;
	cv.push_back(t);
	ret = max(ret, btk(t + 1));
	cv.pop_back();
	return ret;
}

int get(int x){
	v.clear();
	v.push_back(x);
	if(e[x].empty()) return 1;
	for(auto &i : e[x]){
		if(!pro[i]) v.push_back(i);
	}
	sort(v.begin(), v.end());
	vs = int(v.size());
	if(vs <= 2) return vs;
	for(int i = 0; i < vs; i++){
		for(int j = 0; j < vs; j++){
			a[i][j] = (ss.find({v[i], v[j]}) != ss.end());
		}
	}
	return btk(0);
}

int main(){
	scanf("%d%d", &n, &k);
	for(int i = 1, t; i <= n; i++){
		scanf("%d", &t);
		for(int x; t--; ){
			scanf("%d", &x); x++;
			if(i < x){
				ss.insert({i, x});
				e[i].push_back(x);
				e[x].push_back(i);
				d[i]++; d[x]++;
			}
		}
	}
	for(int i = 1; i <= n; i++){
		if(d[i] < k){
			q.push(i);
			chk[i] = 1;
		}
	}
	for(int t = n - k + 1; t--;){
		int cur = q.front(); q.pop();
		ans = max(ans, get(cur));
		pro[cur] = 1;
		if(!e[cur].empty()){
			for(auto &j : e[cur]){
				d[j]--;
				if(!chk[j] && d[j] < k){
					q.push(j);
					chk[j] = 1;
				}
			}
		}
	}
	printf("%d\n", ans);
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:39: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:41:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &t);
   ~~~~~^~~~~~~~~~
politicaldevelopment.cpp:43:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &x); x++;
    ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1528 KB Output is correct
2 Correct 3 ms 1532 KB Output is correct
3 Correct 7 ms 2044 KB Output is correct
4 Correct 7 ms 2040 KB Output is correct
5 Correct 7 ms 2040 KB Output is correct
6 Correct 7 ms 2040 KB Output is correct
7 Correct 7 ms 2044 KB Output is correct
8 Correct 4 ms 1528 KB Output is correct
9 Correct 3 ms 1528 KB Output is correct
10 Correct 4 ms 1528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1528 KB Output is correct
2 Correct 3 ms 1532 KB Output is correct
3 Correct 7 ms 2044 KB Output is correct
4 Correct 7 ms 2040 KB Output is correct
5 Correct 7 ms 2040 KB Output is correct
6 Correct 7 ms 2040 KB Output is correct
7 Correct 7 ms 2044 KB Output is correct
8 Correct 4 ms 1528 KB Output is correct
9 Correct 3 ms 1528 KB Output is correct
10 Correct 4 ms 1528 KB Output is correct
11 Correct 7 ms 2040 KB Output is correct
12 Correct 7 ms 2040 KB Output is correct
13 Correct 3 ms 1528 KB Output is correct
14 Correct 7 ms 2040 KB Output is correct
15 Correct 3 ms 1528 KB Output is correct
16 Correct 7 ms 2040 KB Output is correct
17 Correct 6 ms 1528 KB Output is correct
18 Correct 7 ms 2040 KB Output is correct
19 Correct 4 ms 1532 KB Output is correct
20 Correct 5 ms 1912 KB Output is correct
21 Correct 6 ms 1884 KB Output is correct
22 Correct 4 ms 1528 KB Output is correct
23 Correct 11 ms 2164 KB Output is correct
24 Correct 9 ms 1528 KB Output is correct
25 Correct 10 ms 2040 KB Output is correct
26 Correct 9 ms 2040 KB Output is correct
27 Correct 8 ms 2040 KB Output is correct
28 Correct 9 ms 2040 KB Output is correct
29 Correct 8 ms 2040 KB Output is correct
30 Correct 10 ms 2168 KB Output is correct
31 Correct 11 ms 2040 KB Output is correct
32 Correct 10 ms 2168 KB Output is correct
33 Correct 11 ms 2168 KB Output is correct
34 Correct 10 ms 2168 KB Output is correct
35 Correct 7 ms 1784 KB Output is correct
36 Correct 7 ms 1784 KB Output is correct
37 Correct 7 ms 1784 KB Output is correct
38 Correct 5 ms 1656 KB Output is correct
39 Correct 6 ms 1784 KB Output is correct
40 Correct 16 ms 2296 KB Output is correct
41 Correct 6 ms 1784 KB Output is correct
42 Correct 16 ms 2296 KB Output is correct
43 Correct 17 ms 2324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 1528 KB Output is correct
2 Correct 4 ms 1656 KB Output is correct
3 Correct 4 ms 1656 KB Output is correct
4 Correct 3 ms 1528 KB Output is correct
5 Correct 5 ms 1528 KB Output is correct
6 Correct 4 ms 1528 KB Output is correct
7 Correct 3 ms 1528 KB Output is correct
8 Correct 3 ms 1528 KB Output is correct
9 Correct 3 ms 1528 KB Output is correct
10 Correct 3 ms 1528 KB Output is correct
11 Correct 486 ms 20320 KB Output is correct
12 Correct 3 ms 1532 KB Output is correct
13 Correct 493 ms 20344 KB Output is correct
14 Correct 3 ms 1532 KB Output is correct
15 Correct 516 ms 20472 KB Output is correct
16 Correct 519 ms 20472 KB Output is correct
17 Correct 528 ms 20472 KB Output is correct
18 Correct 473 ms 20344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1528 KB Output is correct
2 Correct 3 ms 1532 KB Output is correct
3 Correct 7 ms 2044 KB Output is correct
4 Correct 7 ms 2040 KB Output is correct
5 Correct 7 ms 2040 KB Output is correct
6 Correct 7 ms 2040 KB Output is correct
7 Correct 7 ms 2044 KB Output is correct
8 Correct 4 ms 1528 KB Output is correct
9 Correct 3 ms 1528 KB Output is correct
10 Correct 4 ms 1528 KB Output is correct
11 Correct 7 ms 2040 KB Output is correct
12 Correct 7 ms 2040 KB Output is correct
13 Correct 3 ms 1528 KB Output is correct
14 Correct 7 ms 2040 KB Output is correct
15 Correct 3 ms 1528 KB Output is correct
16 Correct 7 ms 2040 KB Output is correct
17 Correct 6 ms 1528 KB Output is correct
18 Correct 7 ms 2040 KB Output is correct
19 Correct 4 ms 1532 KB Output is correct
20 Correct 5 ms 1912 KB Output is correct
21 Correct 6 ms 1884 KB Output is correct
22 Correct 4 ms 1528 KB Output is correct
23 Correct 11 ms 2164 KB Output is correct
24 Correct 9 ms 1528 KB Output is correct
25 Correct 10 ms 2040 KB Output is correct
26 Correct 9 ms 2040 KB Output is correct
27 Correct 8 ms 2040 KB Output is correct
28 Correct 9 ms 2040 KB Output is correct
29 Correct 8 ms 2040 KB Output is correct
30 Correct 10 ms 2168 KB Output is correct
31 Correct 11 ms 2040 KB Output is correct
32 Correct 10 ms 2168 KB Output is correct
33 Correct 11 ms 2168 KB Output is correct
34 Correct 10 ms 2168 KB Output is correct
35 Correct 7 ms 1784 KB Output is correct
36 Correct 7 ms 1784 KB Output is correct
37 Correct 7 ms 1784 KB Output is correct
38 Correct 5 ms 1656 KB Output is correct
39 Correct 6 ms 1784 KB Output is correct
40 Correct 16 ms 2296 KB Output is correct
41 Correct 6 ms 1784 KB Output is correct
42 Correct 16 ms 2296 KB Output is correct
43 Correct 17 ms 2324 KB Output is correct
44 Correct 35 ms 3064 KB Output is correct
45 Correct 3 ms 1528 KB Output is correct
46 Correct 16 ms 2296 KB Output is correct
47 Correct 32 ms 3064 KB Output is correct
48 Correct 15 ms 2296 KB Output is correct
49 Correct 32 ms 3064 KB Output is correct
50 Correct 31 ms 3064 KB Output is correct
51 Correct 73 ms 4472 KB Output is correct
52 Correct 7 ms 2040 KB Output is correct
53 Correct 63 ms 4984 KB Output is correct
54 Correct 87 ms 4728 KB Output is correct
55 Correct 7 ms 2040 KB Output is correct
56 Correct 7 ms 2040 KB Output is correct
57 Correct 4 ms 1528 KB Output is correct
58 Correct 61 ms 4856 KB Output is correct
59 Correct 15 ms 2300 KB Output is correct
60 Correct 8 ms 2040 KB Output is correct
61 Correct 15 ms 2300 KB Output is correct
62 Correct 15 ms 2296 KB Output is correct
63 Correct 38 ms 3064 KB Output is correct
64 Correct 28 ms 2936 KB Output is correct
65 Correct 14 ms 2296 KB Output is correct
66 Correct 15 ms 2296 KB Output is correct
67 Correct 41 ms 3312 KB Output is correct
68 Correct 28 ms 2940 KB Output is correct
69 Correct 14 ms 2296 KB Output is correct
70 Correct 29 ms 2936 KB Output is correct
71 Correct 40 ms 3320 KB Output is correct
72 Correct 40 ms 3320 KB Output is correct
73 Correct 9 ms 2040 KB Output is correct
74 Correct 29 ms 2936 KB Output is correct
75 Correct 39 ms 3320 KB Output is correct
76 Correct 19 ms 2552 KB Output is correct
77 Correct 50 ms 3704 KB Output is correct
78 Correct 8 ms 2040 KB Output is correct
79 Correct 24 ms 2552 KB Output is correct
80 Correct 20 ms 2680 KB Output is correct
81 Correct 51 ms 3728 KB Output is correct
82 Correct 6 ms 1784 KB Output is correct
83 Correct 25 ms 2552 KB Output is correct
84 Correct 35 ms 3320 KB Output is correct
85 Correct 6 ms 1784 KB Output is correct
86 Correct 36 ms 3292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1528 KB Output is correct
2 Correct 3 ms 1532 KB Output is correct
3 Correct 7 ms 2044 KB Output is correct
4 Correct 7 ms 2040 KB Output is correct
5 Correct 7 ms 2040 KB Output is correct
6 Correct 7 ms 2040 KB Output is correct
7 Correct 7 ms 2044 KB Output is correct
8 Correct 4 ms 1528 KB Output is correct
9 Correct 3 ms 1528 KB Output is correct
10 Correct 4 ms 1528 KB Output is correct
11 Correct 7 ms 2040 KB Output is correct
12 Correct 7 ms 2040 KB Output is correct
13 Correct 3 ms 1528 KB Output is correct
14 Correct 7 ms 2040 KB Output is correct
15 Correct 3 ms 1528 KB Output is correct
16 Correct 7 ms 2040 KB Output is correct
17 Correct 6 ms 1528 KB Output is correct
18 Correct 7 ms 2040 KB Output is correct
19 Correct 4 ms 1532 KB Output is correct
20 Correct 5 ms 1912 KB Output is correct
21 Correct 6 ms 1884 KB Output is correct
22 Correct 4 ms 1528 KB Output is correct
23 Correct 11 ms 2164 KB Output is correct
24 Correct 9 ms 1528 KB Output is correct
25 Correct 10 ms 2040 KB Output is correct
26 Correct 9 ms 2040 KB Output is correct
27 Correct 8 ms 2040 KB Output is correct
28 Correct 9 ms 2040 KB Output is correct
29 Correct 8 ms 2040 KB Output is correct
30 Correct 10 ms 2168 KB Output is correct
31 Correct 11 ms 2040 KB Output is correct
32 Correct 10 ms 2168 KB Output is correct
33 Correct 11 ms 2168 KB Output is correct
34 Correct 10 ms 2168 KB Output is correct
35 Correct 7 ms 1784 KB Output is correct
36 Correct 7 ms 1784 KB Output is correct
37 Correct 7 ms 1784 KB Output is correct
38 Correct 5 ms 1656 KB Output is correct
39 Correct 6 ms 1784 KB Output is correct
40 Correct 16 ms 2296 KB Output is correct
41 Correct 6 ms 1784 KB Output is correct
42 Correct 16 ms 2296 KB Output is correct
43 Correct 17 ms 2324 KB Output is correct
44 Correct 3 ms 1528 KB Output is correct
45 Correct 352 ms 13748 KB Output is correct
46 Correct 153 ms 8440 KB Output is correct
47 Correct 346 ms 13812 KB Output is correct
48 Correct 340 ms 13688 KB Output is correct
49 Correct 94 ms 7156 KB Output is correct
50 Correct 322 ms 16484 KB Output is correct
51 Correct 305 ms 13688 KB Output is correct
52 Correct 46 ms 7132 KB Output is correct
53 Correct 45 ms 7028 KB Output is correct
54 Correct 9 ms 2168 KB Output is correct
55 Correct 289 ms 16328 KB Output is correct
56 Correct 31 ms 5368 KB Output is correct
57 Correct 47 ms 7160 KB Output is correct
58 Correct 118 ms 8356 KB Output is correct
59 Correct 31 ms 5368 KB Output is correct
60 Correct 30 ms 5368 KB Output is correct
61 Correct 116 ms 8312 KB Output is correct
62 Correct 75 ms 6976 KB Output is correct
63 Correct 156 ms 9368 KB Output is correct
64 Correct 31 ms 5368 KB Output is correct
65 Correct 214 ms 11176 KB Output is correct
66 Correct 74 ms 6904 KB Output is correct
67 Correct 213 ms 9208 KB Output is correct
68 Correct 200 ms 10616 KB Output is correct
69 Correct 239 ms 11036 KB Output is correct
70 Correct 102 ms 6904 KB Output is correct
71 Correct 287 ms 10744 KB Output is correct
72 Correct 174 ms 8952 KB Output is correct
73 Correct 289 ms 12280 KB Output is correct
74 Correct 76 ms 6904 KB Output is correct
75 Correct 78 ms 5632 KB Output is correct
76 Correct 128 ms 9100 KB Output is correct
77 Correct 252 ms 12160 KB Output is correct
78 Correct 113 ms 7032 KB Output is correct
79 Correct 90 ms 5656 KB Output is correct
80 Correct 41 ms 3704 KB Output is correct
81 Correct 109 ms 6908 KB Output is correct
82 Correct 163 ms 9848 KB Output is correct
83 Correct 35 ms 3636 KB Output is correct
84 Correct 165 ms 9848 KB Output is correct