답안 #758192

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
758192 2023-06-14T08:58:53 Z MetalPower Political Development (BOI17_politicaldevelopment) C++14
100 / 100
1175 ms 70396 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pii pair<int, int>
#define fi first
#define se second

const int MX = 2e5 + 10;

int N, K, vis[MX], sz[MX]; map<pii, int> mp;
vector<int> adj[MX];
priority_queue<pii, vector<pii>, greater<pii>> pq;

int solve(int x){
	vector<int> kew;
	for(int nx : adj[x]){
		if(vis[nx]) continue;
		kew.push_back(nx);
	}

	int ns = kew.size(), mk = 1 << ns, ans = 0;

	for(int mask = 0; mask < mk; mask++){
		int num = 1;
		bool curr = true;
		for(int j = 0; j < ns; j++){
			if((mask >> j & 1) != 1) continue;
			num++;
			if(!mp[make_pair(x, kew[j])]){
				curr = false;
				break;
			}
			for(int k = j + 1; k < ns; k++){
				if((mask >> k & 1) != 1) continue;
				if(!mp[make_pair(kew[k], kew[j])]){
					curr = false;
					break;
				}
			}
		}
		if(curr) ans = max(ans, num);
	}
	return ans;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> N >> K;
	for(int i = 0; i < N; i++){
		int v; cin >> sz[i];
		for(int j = 0; j < sz[i]; j++){
			cin >> v;
			adj[i].push_back(v);
			mp[make_pair(i, v)] = 1;
		}
	}

	for(int i = 0; i < N; i++) pq.push({sz[i], i});

	int mx = 1;
	for(;!pq.empty();){
		int curr = pq.top().se; pq.pop();
		if(vis[curr]) continue;
		mx = max(mx, solve(curr));
		vis[curr] = 1;
		for(int nx : adj[curr]){
			if(!vis[nx]){
				sz[nx]--;
				pq.push({sz[nx], nx});
			}
		}
	}
	cout << mx << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4948 KB Output is correct
2 Correct 3 ms 5024 KB Output is correct
3 Correct 9 ms 6028 KB Output is correct
4 Correct 8 ms 5972 KB Output is correct
5 Correct 7 ms 6044 KB Output is correct
6 Correct 8 ms 6040 KB Output is correct
7 Correct 7 ms 5936 KB Output is correct
8 Correct 4 ms 5076 KB Output is correct
9 Correct 4 ms 4948 KB Output is correct
10 Correct 4 ms 5076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4948 KB Output is correct
2 Correct 3 ms 5024 KB Output is correct
3 Correct 9 ms 6028 KB Output is correct
4 Correct 8 ms 5972 KB Output is correct
5 Correct 7 ms 6044 KB Output is correct
6 Correct 8 ms 6040 KB Output is correct
7 Correct 7 ms 5936 KB Output is correct
8 Correct 4 ms 5076 KB Output is correct
9 Correct 4 ms 4948 KB Output is correct
10 Correct 4 ms 5076 KB Output is correct
11 Correct 8 ms 5972 KB Output is correct
12 Correct 8 ms 5972 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 8 ms 5936 KB Output is correct
15 Correct 3 ms 5028 KB Output is correct
16 Correct 7 ms 5972 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 7 ms 5972 KB Output is correct
19 Correct 3 ms 5076 KB Output is correct
20 Correct 5 ms 5588 KB Output is correct
21 Correct 6 ms 5588 KB Output is correct
22 Correct 4 ms 5196 KB Output is correct
23 Correct 10 ms 6172 KB Output is correct
24 Correct 4 ms 5168 KB Output is correct
25 Correct 11 ms 6232 KB Output is correct
26 Correct 10 ms 6068 KB Output is correct
27 Correct 7 ms 5972 KB Output is correct
28 Correct 9 ms 6100 KB Output is correct
29 Correct 7 ms 5940 KB Output is correct
30 Correct 10 ms 6228 KB Output is correct
31 Correct 11 ms 6228 KB Output is correct
32 Correct 9 ms 6228 KB Output is correct
33 Correct 9 ms 6228 KB Output is correct
34 Correct 10 ms 6280 KB Output is correct
35 Correct 7 ms 5588 KB Output is correct
36 Correct 7 ms 5588 KB Output is correct
37 Correct 7 ms 5636 KB Output is correct
38 Correct 5 ms 5460 KB Output is correct
39 Correct 6 ms 5420 KB Output is correct
40 Correct 15 ms 6996 KB Output is correct
41 Correct 6 ms 5460 KB Output is correct
42 Correct 15 ms 6996 KB Output is correct
43 Correct 15 ms 6996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5076 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 5028 KB Output is correct
4 Correct 4 ms 5024 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 4 ms 5024 KB Output is correct
7 Correct 4 ms 4936 KB Output is correct
8 Correct 4 ms 4948 KB Output is correct
9 Correct 3 ms 5032 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 1122 ms 70396 KB Output is correct
12 Correct 3 ms 4948 KB Output is correct
13 Correct 1135 ms 70264 KB Output is correct
14 Correct 3 ms 4948 KB Output is correct
15 Correct 1175 ms 70212 KB Output is correct
16 Correct 1159 ms 70356 KB Output is correct
17 Correct 1169 ms 70240 KB Output is correct
18 Correct 1101 ms 70176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4948 KB Output is correct
2 Correct 3 ms 5024 KB Output is correct
3 Correct 9 ms 6028 KB Output is correct
4 Correct 8 ms 5972 KB Output is correct
5 Correct 7 ms 6044 KB Output is correct
6 Correct 8 ms 6040 KB Output is correct
7 Correct 7 ms 5936 KB Output is correct
8 Correct 4 ms 5076 KB Output is correct
9 Correct 4 ms 4948 KB Output is correct
10 Correct 4 ms 5076 KB Output is correct
11 Correct 8 ms 5972 KB Output is correct
12 Correct 8 ms 5972 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 8 ms 5936 KB Output is correct
15 Correct 3 ms 5028 KB Output is correct
16 Correct 7 ms 5972 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 7 ms 5972 KB Output is correct
19 Correct 3 ms 5076 KB Output is correct
20 Correct 5 ms 5588 KB Output is correct
21 Correct 6 ms 5588 KB Output is correct
22 Correct 4 ms 5196 KB Output is correct
23 Correct 10 ms 6172 KB Output is correct
24 Correct 4 ms 5168 KB Output is correct
25 Correct 11 ms 6232 KB Output is correct
26 Correct 10 ms 6068 KB Output is correct
27 Correct 7 ms 5972 KB Output is correct
28 Correct 9 ms 6100 KB Output is correct
29 Correct 7 ms 5940 KB Output is correct
30 Correct 10 ms 6228 KB Output is correct
31 Correct 11 ms 6228 KB Output is correct
32 Correct 9 ms 6228 KB Output is correct
33 Correct 9 ms 6228 KB Output is correct
34 Correct 10 ms 6280 KB Output is correct
35 Correct 7 ms 5588 KB Output is correct
36 Correct 7 ms 5588 KB Output is correct
37 Correct 7 ms 5636 KB Output is correct
38 Correct 5 ms 5460 KB Output is correct
39 Correct 6 ms 5420 KB Output is correct
40 Correct 15 ms 6996 KB Output is correct
41 Correct 6 ms 5460 KB Output is correct
42 Correct 15 ms 6996 KB Output is correct
43 Correct 15 ms 6996 KB Output is correct
44 Correct 138 ms 8096 KB Output is correct
45 Correct 3 ms 4948 KB Output is correct
46 Correct 16 ms 7032 KB Output is correct
47 Correct 64 ms 9964 KB Output is correct
48 Correct 16 ms 6960 KB Output is correct
49 Correct 49 ms 10020 KB Output is correct
50 Correct 56 ms 10020 KB Output is correct
51 Correct 511 ms 19700 KB Output is correct
52 Correct 7 ms 5972 KB Output is correct
53 Correct 893 ms 12376 KB Output is correct
54 Correct 1014 ms 22844 KB Output is correct
55 Correct 7 ms 5972 KB Output is correct
56 Correct 8 ms 5972 KB Output is correct
57 Correct 3 ms 5076 KB Output is correct
58 Correct 900 ms 12360 KB Output is correct
59 Correct 18 ms 6572 KB Output is correct
60 Correct 8 ms 5932 KB Output is correct
61 Correct 17 ms 6632 KB Output is correct
62 Correct 17 ms 6692 KB Output is correct
63 Correct 149 ms 8020 KB Output is correct
64 Correct 69 ms 7764 KB Output is correct
65 Correct 15 ms 6768 KB Output is correct
66 Correct 16 ms 6580 KB Output is correct
67 Correct 118 ms 11392 KB Output is correct
68 Correct 93 ms 7760 KB Output is correct
69 Correct 14 ms 6764 KB Output is correct
70 Correct 71 ms 9228 KB Output is correct
71 Correct 109 ms 11280 KB Output is correct
72 Correct 97 ms 11044 KB Output is correct
73 Correct 8 ms 5972 KB Output is correct
74 Correct 46 ms 9312 KB Output is correct
75 Correct 96 ms 11120 KB Output is correct
76 Correct 31 ms 7756 KB Output is correct
77 Correct 190 ms 14152 KB Output is correct
78 Correct 7 ms 5932 KB Output is correct
79 Correct 91 ms 9596 KB Output is correct
80 Correct 25 ms 7864 KB Output is correct
81 Correct 188 ms 14260 KB Output is correct
82 Correct 5 ms 5460 KB Output is correct
83 Correct 91 ms 9540 KB Output is correct
84 Correct 87 ms 11468 KB Output is correct
85 Correct 5 ms 5416 KB Output is correct
86 Correct 106 ms 11464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4948 KB Output is correct
2 Correct 3 ms 5024 KB Output is correct
3 Correct 9 ms 6028 KB Output is correct
4 Correct 8 ms 5972 KB Output is correct
5 Correct 7 ms 6044 KB Output is correct
6 Correct 8 ms 6040 KB Output is correct
7 Correct 7 ms 5936 KB Output is correct
8 Correct 4 ms 5076 KB Output is correct
9 Correct 4 ms 4948 KB Output is correct
10 Correct 4 ms 5076 KB Output is correct
11 Correct 8 ms 5972 KB Output is correct
12 Correct 8 ms 5972 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 8 ms 5936 KB Output is correct
15 Correct 3 ms 5028 KB Output is correct
16 Correct 7 ms 5972 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 7 ms 5972 KB Output is correct
19 Correct 3 ms 5076 KB Output is correct
20 Correct 5 ms 5588 KB Output is correct
21 Correct 6 ms 5588 KB Output is correct
22 Correct 4 ms 5196 KB Output is correct
23 Correct 10 ms 6172 KB Output is correct
24 Correct 4 ms 5168 KB Output is correct
25 Correct 11 ms 6232 KB Output is correct
26 Correct 10 ms 6068 KB Output is correct
27 Correct 7 ms 5972 KB Output is correct
28 Correct 9 ms 6100 KB Output is correct
29 Correct 7 ms 5940 KB Output is correct
30 Correct 10 ms 6228 KB Output is correct
31 Correct 11 ms 6228 KB Output is correct
32 Correct 9 ms 6228 KB Output is correct
33 Correct 9 ms 6228 KB Output is correct
34 Correct 10 ms 6280 KB Output is correct
35 Correct 7 ms 5588 KB Output is correct
36 Correct 7 ms 5588 KB Output is correct
37 Correct 7 ms 5636 KB Output is correct
38 Correct 5 ms 5460 KB Output is correct
39 Correct 6 ms 5420 KB Output is correct
40 Correct 15 ms 6996 KB Output is correct
41 Correct 6 ms 5460 KB Output is correct
42 Correct 15 ms 6996 KB Output is correct
43 Correct 15 ms 6996 KB Output is correct
44 Correct 4 ms 5024 KB Output is correct
45 Correct 369 ms 38864 KB Output is correct
46 Correct 131 ms 18920 KB Output is correct
47 Correct 376 ms 39308 KB Output is correct
48 Correct 354 ms 38940 KB Output is correct
49 Correct 61 ms 14748 KB Output is correct
50 Correct 375 ms 37372 KB Output is correct
51 Correct 379 ms 39136 KB Output is correct
52 Correct 51 ms 14604 KB Output is correct
53 Correct 63 ms 14748 KB Output is correct
54 Correct 10 ms 5976 KB Output is correct
55 Correct 352 ms 37364 KB Output is correct
56 Correct 34 ms 10948 KB Output is correct
57 Correct 50 ms 14608 KB Output is correct
58 Correct 116 ms 17796 KB Output is correct
59 Correct 35 ms 10984 KB Output is correct
60 Correct 33 ms 10988 KB Output is correct
61 Correct 108 ms 17844 KB Output is correct
62 Correct 66 ms 14312 KB Output is correct
63 Correct 147 ms 21920 KB Output is correct
64 Correct 35 ms 10916 KB Output is correct
65 Correct 227 ms 27964 KB Output is correct
66 Correct 88 ms 14484 KB Output is correct
67 Correct 154 ms 21912 KB Output is correct
68 Correct 199 ms 26712 KB Output is correct
69 Correct 263 ms 28068 KB Output is correct
70 Correct 74 ms 14412 KB Output is correct
71 Correct 197 ms 26804 KB Output is correct
72 Correct 132 ms 21284 KB Output is correct
73 Correct 310 ms 33024 KB Output is correct
74 Correct 65 ms 14348 KB Output is correct
75 Correct 80 ms 14668 KB Output is correct
76 Correct 133 ms 21268 KB Output is correct
77 Correct 286 ms 32972 KB Output is correct
78 Correct 144 ms 18924 KB Output is correct
79 Correct 80 ms 14712 KB Output is correct
80 Correct 32 ms 9900 KB Output is correct
81 Correct 131 ms 18920 KB Output is correct
82 Correct 209 ms 25152 KB Output is correct
83 Correct 33 ms 9804 KB Output is correct
84 Correct 182 ms 25172 KB Output is correct