답안 #864710

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
864710 2023-10-23T13:28:17 Z iskhakkutbilim Political Development (BOI17_politicaldevelopment) C++17
100 / 100
216 ms 316840 KB
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
const int N = 50000;
int n, k;
int deg[N];
vector<int> g[N];
bitset<N> yes[N];
 
bool can(vector<int>&v){
	for(int i = 0;i < v.size(); i++){
		for(int j = i +1;j < v.size(); j++){
			if(yes[v[i]][v[j]] == 0) return false;
		}
	}
	return true;
}
 
 
main(){
   ios::sync_with_stdio(0);
   cin.tie(0); cout.tie(0);
	cin >> n >> k;
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int> > > pq;
	for(int i = 0;i < n; i++){
		int sz; cin >> sz;
		deg[i] = sz;
		pq.push({deg[i], i});
		for(int j = 0;j < sz; j++){
			int x; cin >> x;
			yes[i][x] = 1;
			g[i].push_back(x);
		}
	}	
	int ans = 1;
	vector<int> used(n, 0);
	while(true){
		while(!pq.empty() && used[pq.top().ss]) pq.pop();
		if(pq.empty()) break;
		int v = pq.top().ss;
		pq.pop();
		used[v] = 1;
		deg[v] = 0;
		vector<int> vert = {v};
		for(int to : g[v]){
			if(used[to]) continue;
			deg[to]--;
			pq.push({deg[to], to});
			vert.push_back(to);
		}
		bool adj[11][11] = {};
		for(int i = 0;i < vert.size(); i++){
			adj[i][i] = 1;
			for(int j = 0; j < vert.size(); j++){
				if(i != j && yes[vert[i]][vert[j]]){
					adj[i][j] = 1;
				}
			}
		}
		for(int mask = 1; mask < (1<<vert.size()); mask++){
			int ok = 1, cnt = 0;
			for(int i = 0;i < vert.size() && ok; i++){
				if(!(mask & (1<<i))) continue;
				cnt++;
				for(int j = 0;j < vert.size(); j++){
					if(mask & (1<<j)){
						if(adj[i][j] == 0){
							ok = 0;
							break;
						}
					}
				}
			}
			if(ok) ans = max(ans, cnt);
		}
	}
	cout << ans;
	return 0;
}

Compilation message

politicaldevelopment.cpp: In function 'bool can(std::vector<int>&)':
politicaldevelopment.cpp:14:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for(int i = 0;i < v.size(); i++){
      |                ~~^~~~~~~~~~
politicaldevelopment.cpp:15:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |   for(int j = i +1;j < v.size(); j++){
      |                    ~~^~~~~~~~~~
politicaldevelopment.cpp: At global scope:
politicaldevelopment.cpp:23:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   23 | main(){
      | ^~~~
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:55:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |   for(int i = 0;i < vert.size(); i++){
      |                 ~~^~~~~~~~~~~~~
politicaldevelopment.cpp:57:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |    for(int j = 0; j < vert.size(); j++){
      |                   ~~^~~~~~~~~~~~~
politicaldevelopment.cpp:65:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |    for(int i = 0;i < vert.size() && ok; i++){
      |                  ~~^~~~~~~~~~~~~
politicaldevelopment.cpp:68:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |     for(int j = 0;j < vert.size(); j++){
      |                   ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Correct 7 ms 32840 KB Output is correct
4 Correct 6 ms 32860 KB Output is correct
5 Correct 6 ms 32860 KB Output is correct
6 Correct 6 ms 32860 KB Output is correct
7 Correct 6 ms 32860 KB Output is correct
8 Correct 1 ms 1644 KB Output is correct
9 Correct 1 ms 1628 KB Output is correct
10 Correct 2 ms 5724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Correct 7 ms 32840 KB Output is correct
4 Correct 6 ms 32860 KB Output is correct
5 Correct 6 ms 32860 KB Output is correct
6 Correct 6 ms 32860 KB Output is correct
7 Correct 6 ms 32860 KB Output is correct
8 Correct 1 ms 1644 KB Output is correct
9 Correct 1 ms 1628 KB Output is correct
10 Correct 2 ms 5724 KB Output is correct
11 Correct 6 ms 32604 KB Output is correct
12 Correct 6 ms 32776 KB Output is correct
13 Correct 1 ms 1628 KB Output is correct
14 Correct 6 ms 32604 KB Output is correct
15 Correct 1 ms 1624 KB Output is correct
16 Correct 6 ms 32856 KB Output is correct
17 Correct 1 ms 1628 KB Output is correct
18 Correct 6 ms 32868 KB Output is correct
19 Correct 1 ms 1648 KB Output is correct
20 Correct 6 ms 32604 KB Output is correct
21 Correct 6 ms 32604 KB Output is correct
22 Correct 2 ms 5724 KB Output is correct
23 Correct 8 ms 32596 KB Output is correct
24 Correct 2 ms 5724 KB Output is correct
25 Correct 8 ms 32760 KB Output is correct
26 Correct 7 ms 32600 KB Output is correct
27 Correct 7 ms 32604 KB Output is correct
28 Correct 7 ms 32604 KB Output is correct
29 Correct 7 ms 32604 KB Output is correct
30 Correct 7 ms 32840 KB Output is correct
31 Correct 8 ms 32860 KB Output is correct
32 Correct 7 ms 32860 KB Output is correct
33 Correct 8 ms 32860 KB Output is correct
34 Correct 8 ms 32860 KB Output is correct
35 Correct 4 ms 18268 KB Output is correct
36 Correct 4 ms 18268 KB Output is correct
37 Correct 4 ms 18268 KB Output is correct
38 Correct 3 ms 10076 KB Output is correct
39 Correct 3 ms 10076 KB Output is correct
40 Correct 9 ms 32860 KB Output is correct
41 Correct 2 ms 10076 KB Output is correct
42 Correct 10 ms 33020 KB Output is correct
43 Correct 9 ms 32920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1724 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Correct 1 ms 1628 KB Output is correct
4 Correct 1 ms 1628 KB Output is correct
5 Correct 1 ms 1628 KB Output is correct
6 Correct 1 ms 1628 KB Output is correct
7 Correct 1 ms 1628 KB Output is correct
8 Correct 1 ms 1628 KB Output is correct
9 Correct 1 ms 1628 KB Output is correct
10 Correct 1 ms 1628 KB Output is correct
11 Correct 216 ms 316604 KB Output is correct
12 Correct 1 ms 1628 KB Output is correct
13 Correct 213 ms 316840 KB Output is correct
14 Correct 1 ms 1628 KB Output is correct
15 Correct 206 ms 316512 KB Output is correct
16 Correct 207 ms 316620 KB Output is correct
17 Correct 208 ms 316588 KB Output is correct
18 Correct 214 ms 316628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Correct 7 ms 32840 KB Output is correct
4 Correct 6 ms 32860 KB Output is correct
5 Correct 6 ms 32860 KB Output is correct
6 Correct 6 ms 32860 KB Output is correct
7 Correct 6 ms 32860 KB Output is correct
8 Correct 1 ms 1644 KB Output is correct
9 Correct 1 ms 1628 KB Output is correct
10 Correct 2 ms 5724 KB Output is correct
11 Correct 6 ms 32604 KB Output is correct
12 Correct 6 ms 32776 KB Output is correct
13 Correct 1 ms 1628 KB Output is correct
14 Correct 6 ms 32604 KB Output is correct
15 Correct 1 ms 1624 KB Output is correct
16 Correct 6 ms 32856 KB Output is correct
17 Correct 1 ms 1628 KB Output is correct
18 Correct 6 ms 32868 KB Output is correct
19 Correct 1 ms 1648 KB Output is correct
20 Correct 6 ms 32604 KB Output is correct
21 Correct 6 ms 32604 KB Output is correct
22 Correct 2 ms 5724 KB Output is correct
23 Correct 8 ms 32596 KB Output is correct
24 Correct 2 ms 5724 KB Output is correct
25 Correct 8 ms 32760 KB Output is correct
26 Correct 7 ms 32600 KB Output is correct
27 Correct 7 ms 32604 KB Output is correct
28 Correct 7 ms 32604 KB Output is correct
29 Correct 7 ms 32604 KB Output is correct
30 Correct 7 ms 32840 KB Output is correct
31 Correct 8 ms 32860 KB Output is correct
32 Correct 7 ms 32860 KB Output is correct
33 Correct 8 ms 32860 KB Output is correct
34 Correct 8 ms 32860 KB Output is correct
35 Correct 4 ms 18268 KB Output is correct
36 Correct 4 ms 18268 KB Output is correct
37 Correct 4 ms 18268 KB Output is correct
38 Correct 3 ms 10076 KB Output is correct
39 Correct 3 ms 10076 KB Output is correct
40 Correct 9 ms 32860 KB Output is correct
41 Correct 2 ms 10076 KB Output is correct
42 Correct 10 ms 33020 KB Output is correct
43 Correct 9 ms 32920 KB Output is correct
44 Correct 92 ms 32860 KB Output is correct
45 Correct 1 ms 1628 KB Output is correct
46 Correct 9 ms 32928 KB Output is correct
47 Correct 16 ms 33624 KB Output is correct
48 Correct 9 ms 32860 KB Output is correct
49 Correct 14 ms 33368 KB Output is correct
50 Correct 15 ms 33368 KB Output is correct
51 Correct 63 ms 34000 KB Output is correct
52 Correct 6 ms 32604 KB Output is correct
53 Correct 110 ms 34000 KB Output is correct
54 Correct 121 ms 34028 KB Output is correct
55 Correct 6 ms 32856 KB Output is correct
56 Correct 6 ms 32604 KB Output is correct
57 Correct 1 ms 1628 KB Output is correct
58 Correct 111 ms 34136 KB Output is correct
59 Correct 9 ms 32856 KB Output is correct
60 Correct 6 ms 32860 KB Output is correct
61 Correct 9 ms 32860 KB Output is correct
62 Correct 9 ms 32776 KB Output is correct
63 Correct 97 ms 33036 KB Output is correct
64 Correct 40 ms 32856 KB Output is correct
65 Correct 8 ms 32856 KB Output is correct
66 Correct 9 ms 32860 KB Output is correct
67 Correct 40 ms 33376 KB Output is correct
68 Correct 40 ms 32856 KB Output is correct
69 Correct 9 ms 32860 KB Output is correct
70 Correct 14 ms 33120 KB Output is correct
71 Correct 39 ms 33372 KB Output is correct
72 Correct 24 ms 33368 KB Output is correct
73 Correct 7 ms 32604 KB Output is correct
74 Correct 14 ms 33116 KB Output is correct
75 Correct 24 ms 33460 KB Output is correct
76 Correct 10 ms 33100 KB Output is correct
77 Correct 30 ms 33496 KB Output is correct
78 Correct 6 ms 32604 KB Output is correct
79 Correct 15 ms 18740 KB Output is correct
80 Correct 10 ms 33116 KB Output is correct
81 Correct 30 ms 33512 KB Output is correct
82 Correct 3 ms 10076 KB Output is correct
83 Correct 16 ms 18524 KB Output is correct
84 Correct 19 ms 33372 KB Output is correct
85 Correct 3 ms 10076 KB Output is correct
86 Correct 18 ms 33372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Correct 7 ms 32840 KB Output is correct
4 Correct 6 ms 32860 KB Output is correct
5 Correct 6 ms 32860 KB Output is correct
6 Correct 6 ms 32860 KB Output is correct
7 Correct 6 ms 32860 KB Output is correct
8 Correct 1 ms 1644 KB Output is correct
9 Correct 1 ms 1628 KB Output is correct
10 Correct 2 ms 5724 KB Output is correct
11 Correct 6 ms 32604 KB Output is correct
12 Correct 6 ms 32776 KB Output is correct
13 Correct 1 ms 1628 KB Output is correct
14 Correct 6 ms 32604 KB Output is correct
15 Correct 1 ms 1624 KB Output is correct
16 Correct 6 ms 32856 KB Output is correct
17 Correct 1 ms 1628 KB Output is correct
18 Correct 6 ms 32868 KB Output is correct
19 Correct 1 ms 1648 KB Output is correct
20 Correct 6 ms 32604 KB Output is correct
21 Correct 6 ms 32604 KB Output is correct
22 Correct 2 ms 5724 KB Output is correct
23 Correct 8 ms 32596 KB Output is correct
24 Correct 2 ms 5724 KB Output is correct
25 Correct 8 ms 32760 KB Output is correct
26 Correct 7 ms 32600 KB Output is correct
27 Correct 7 ms 32604 KB Output is correct
28 Correct 7 ms 32604 KB Output is correct
29 Correct 7 ms 32604 KB Output is correct
30 Correct 7 ms 32840 KB Output is correct
31 Correct 8 ms 32860 KB Output is correct
32 Correct 7 ms 32860 KB Output is correct
33 Correct 8 ms 32860 KB Output is correct
34 Correct 8 ms 32860 KB Output is correct
35 Correct 4 ms 18268 KB Output is correct
36 Correct 4 ms 18268 KB Output is correct
37 Correct 4 ms 18268 KB Output is correct
38 Correct 3 ms 10076 KB Output is correct
39 Correct 3 ms 10076 KB Output is correct
40 Correct 9 ms 32860 KB Output is correct
41 Correct 2 ms 10076 KB Output is correct
42 Correct 10 ms 33020 KB Output is correct
43 Correct 9 ms 32920 KB Output is correct
44 Correct 1 ms 1624 KB Output is correct
45 Correct 114 ms 314036 KB Output is correct
46 Correct 75 ms 311092 KB Output is correct
47 Correct 128 ms 314152 KB Output is correct
48 Correct 113 ms 314232 KB Output is correct
49 Correct 56 ms 310684 KB Output is correct
50 Correct 116 ms 314820 KB Output is correct
51 Correct 118 ms 314052 KB Output is correct
52 Correct 61 ms 310980 KB Output is correct
53 Correct 56 ms 310728 KB Output is correct
54 Correct 8 ms 2528 KB Output is correct
55 Correct 116 ms 314764 KB Output is correct
56 Correct 50 ms 310220 KB Output is correct
57 Correct 59 ms 310716 KB Output is correct
58 Correct 69 ms 310732 KB Output is correct
59 Correct 53 ms 310308 KB Output is correct
60 Correct 50 ms 310220 KB Output is correct
61 Correct 70 ms 310728 KB Output is correct
62 Correct 61 ms 310400 KB Output is correct
63 Correct 88 ms 311756 KB Output is correct
64 Correct 51 ms 310220 KB Output is correct
65 Correct 95 ms 312396 KB Output is correct
66 Correct 59 ms 310424 KB Output is correct
67 Correct 88 ms 311936 KB Output is correct
68 Correct 93 ms 312120 KB Output is correct
69 Correct 96 ms 312392 KB Output is correct
70 Correct 63 ms 310476 KB Output is correct
71 Correct 93 ms 312264 KB Output is correct
72 Correct 84 ms 311812 KB Output is correct
73 Correct 104 ms 312660 KB Output is correct
74 Correct 62 ms 310476 KB Output is correct
75 Correct 44 ms 157656 KB Output is correct
76 Correct 78 ms 311860 KB Output is correct
77 Correct 112 ms 312520 KB Output is correct
78 Correct 51 ms 158156 KB Output is correct
79 Correct 46 ms 157844 KB Output is correct
80 Correct 19 ms 80720 KB Output is correct
81 Correct 51 ms 158168 KB Output is correct
82 Correct 87 ms 311756 KB Output is correct
83 Correct 23 ms 80984 KB Output is correct
84 Correct 87 ms 311756 KB Output is correct