Submission #272272

# Submission time Handle Problem Language Result Execution time Memory
272272 2020-08-18T11:11:52 Z brcode Political Development (BOI17_politicaldevelopment) C++14
100 / 100
783 ms 31268 KB
#include <iostream>
#include <bits/stdc++.h>

using namespace std;
const int MAXN = 1e5+5;
set<int> v1[MAXN];
int n,k;
set<pair<int,int>> s1;
int main(){
	
    cin>>n>>k;
    for(int i=0;i<n;i++){
    	int x;
    	cin>>x;
    	for(int j=1;j<=x;j++){
    		int y;
    		cin>>y;
    		v1[i].insert(y);
    	}
    	s1.insert(make_pair(x,i));
    }
    int ans = 0;
    while(s1.size()){
    	auto it = s1.begin();
    	pair<int,int> hold  = *it;
    	s1.erase(it);
    	//cout<<hold.first<<" "<<hold.second<<endl;
    	vector<int> v2;
    	for(int x:v1[hold.second]){
    		v2.push_back(x);
    		//cout<<x<<" ";
    	}
    //	cout<<endl;
    	int sz = v2.size();
    	for(int msk = 0;msk<(1<<sz);msk++){
    		bool ok = true;
    		for(int i=0;i<v2.size();i++){
    			if(msk&(1<<i)){
    				int node1 = v2[i];
    				for(int j=0;j<v2.size();j++){
    					int node2 = v2[j];
    					if(msk&(1<<j) && node1!=node2){
    						if(v1[node2].count(node1) == 0){
    							ok = false;
    						}
    					}
    					if(!ok){
	    					break;
	    				}
    				}
    				if(!ok){
    					break;
    				}
    				if(v1[node1].count(hold.second) == 0){
    					ok = false;
    				}
    			}
    		}
    		if(ok){
    			ans = max(ans, __builtin_popcount(msk)+1);
    		}
    	}
    	for(int i=0;i<v2.size();i++){
    		s1.erase(make_pair(v1[v2[i]].size(),v2[i]));
    		v1[v2[i]].erase(hold.second);
    		if(v1[v2[i]].size()){
    			s1.insert(make_pair(v1[v2[i]].size(),v2[i]));
    		}
    	}
    }
    cout<<ans<<endl;
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:37:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |       for(int i=0;i<v2.size();i++){
      |                   ~^~~~~~~~~~
politicaldevelopment.cpp:40:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for(int j=0;j<v2.size();j++){
      |                     ~^~~~~~~~~~
politicaldevelopment.cpp:63:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |      for(int i=0;i<v2.size();i++){
      |                  ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4992 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Correct 16 ms 5760 KB Output is correct
4 Correct 15 ms 5760 KB Output is correct
5 Correct 14 ms 5760 KB Output is correct
6 Correct 14 ms 5760 KB Output is correct
7 Correct 18 ms 5760 KB Output is correct
8 Correct 6 ms 5248 KB Output is correct
9 Correct 3 ms 4992 KB Output is correct
10 Correct 6 ms 5248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4992 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Correct 16 ms 5760 KB Output is correct
4 Correct 15 ms 5760 KB Output is correct
5 Correct 14 ms 5760 KB Output is correct
6 Correct 14 ms 5760 KB Output is correct
7 Correct 18 ms 5760 KB Output is correct
8 Correct 6 ms 5248 KB Output is correct
9 Correct 3 ms 4992 KB Output is correct
10 Correct 6 ms 5248 KB Output is correct
11 Correct 14 ms 5760 KB Output is correct
12 Correct 14 ms 5760 KB Output is correct
13 Correct 4 ms 4992 KB Output is correct
14 Correct 14 ms 5760 KB Output is correct
15 Correct 4 ms 4992 KB Output is correct
16 Correct 14 ms 5760 KB Output is correct
17 Correct 3 ms 4992 KB Output is correct
18 Correct 14 ms 5760 KB Output is correct
19 Correct 6 ms 5248 KB Output is correct
20 Correct 9 ms 5504 KB Output is correct
21 Correct 9 ms 5504 KB Output is correct
22 Correct 6 ms 5248 KB Output is correct
23 Correct 18 ms 5888 KB Output is correct
24 Correct 6 ms 5248 KB Output is correct
25 Correct 18 ms 5888 KB Output is correct
26 Correct 17 ms 5888 KB Output is correct
27 Correct 16 ms 5760 KB Output is correct
28 Correct 16 ms 5888 KB Output is correct
29 Correct 13 ms 5760 KB Output is correct
30 Correct 22 ms 5888 KB Output is correct
31 Correct 18 ms 5888 KB Output is correct
32 Correct 19 ms 5888 KB Output is correct
33 Correct 17 ms 5888 KB Output is correct
34 Correct 18 ms 5888 KB Output is correct
35 Correct 10 ms 5504 KB Output is correct
36 Correct 10 ms 5504 KB Output is correct
37 Correct 10 ms 5504 KB Output is correct
38 Correct 8 ms 5376 KB Output is correct
39 Correct 8 ms 5248 KB Output is correct
40 Correct 24 ms 6272 KB Output is correct
41 Correct 9 ms 5376 KB Output is correct
42 Correct 24 ms 6272 KB Output is correct
43 Correct 24 ms 6272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 5248 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Correct 5 ms 4992 KB Output is correct
4 Correct 3 ms 4992 KB Output is correct
5 Correct 4 ms 4992 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 4 ms 4992 KB Output is correct
8 Correct 5 ms 4992 KB Output is correct
9 Correct 4 ms 4992 KB Output is correct
10 Correct 4 ms 4992 KB Output is correct
11 Correct 726 ms 31224 KB Output is correct
12 Correct 4 ms 4992 KB Output is correct
13 Correct 723 ms 31268 KB Output is correct
14 Correct 4 ms 4992 KB Output is correct
15 Correct 735 ms 31200 KB Output is correct
16 Correct 733 ms 31228 KB Output is correct
17 Correct 748 ms 31224 KB Output is correct
18 Correct 783 ms 31224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4992 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Correct 16 ms 5760 KB Output is correct
4 Correct 15 ms 5760 KB Output is correct
5 Correct 14 ms 5760 KB Output is correct
6 Correct 14 ms 5760 KB Output is correct
7 Correct 18 ms 5760 KB Output is correct
8 Correct 6 ms 5248 KB Output is correct
9 Correct 3 ms 4992 KB Output is correct
10 Correct 6 ms 5248 KB Output is correct
11 Correct 14 ms 5760 KB Output is correct
12 Correct 14 ms 5760 KB Output is correct
13 Correct 4 ms 4992 KB Output is correct
14 Correct 14 ms 5760 KB Output is correct
15 Correct 4 ms 4992 KB Output is correct
16 Correct 14 ms 5760 KB Output is correct
17 Correct 3 ms 4992 KB Output is correct
18 Correct 14 ms 5760 KB Output is correct
19 Correct 6 ms 5248 KB Output is correct
20 Correct 9 ms 5504 KB Output is correct
21 Correct 9 ms 5504 KB Output is correct
22 Correct 6 ms 5248 KB Output is correct
23 Correct 18 ms 5888 KB Output is correct
24 Correct 6 ms 5248 KB Output is correct
25 Correct 18 ms 5888 KB Output is correct
26 Correct 17 ms 5888 KB Output is correct
27 Correct 16 ms 5760 KB Output is correct
28 Correct 16 ms 5888 KB Output is correct
29 Correct 13 ms 5760 KB Output is correct
30 Correct 22 ms 5888 KB Output is correct
31 Correct 18 ms 5888 KB Output is correct
32 Correct 19 ms 5888 KB Output is correct
33 Correct 17 ms 5888 KB Output is correct
34 Correct 18 ms 5888 KB Output is correct
35 Correct 10 ms 5504 KB Output is correct
36 Correct 10 ms 5504 KB Output is correct
37 Correct 10 ms 5504 KB Output is correct
38 Correct 8 ms 5376 KB Output is correct
39 Correct 8 ms 5248 KB Output is correct
40 Correct 24 ms 6272 KB Output is correct
41 Correct 9 ms 5376 KB Output is correct
42 Correct 24 ms 6272 KB Output is correct
43 Correct 24 ms 6272 KB Output is correct
44 Correct 144 ms 7368 KB Output is correct
45 Correct 4 ms 4992 KB Output is correct
46 Correct 26 ms 6272 KB Output is correct
47 Correct 50 ms 7288 KB Output is correct
48 Correct 24 ms 6272 KB Output is correct
49 Correct 50 ms 7288 KB Output is correct
50 Correct 45 ms 7288 KB Output is correct
51 Correct 127 ms 9464 KB Output is correct
52 Correct 13 ms 5760 KB Output is correct
53 Correct 154 ms 9936 KB Output is correct
54 Correct 170 ms 9848 KB Output is correct
55 Correct 14 ms 5760 KB Output is correct
56 Correct 16 ms 5760 KB Output is correct
57 Correct 7 ms 5248 KB Output is correct
58 Correct 154 ms 9848 KB Output is correct
59 Correct 22 ms 6272 KB Output is correct
60 Correct 14 ms 5760 KB Output is correct
61 Correct 23 ms 6272 KB Output is correct
62 Correct 22 ms 6272 KB Output is correct
63 Correct 148 ms 7296 KB Output is correct
64 Correct 82 ms 7040 KB Output is correct
65 Correct 21 ms 6144 KB Output is correct
66 Correct 23 ms 6392 KB Output is correct
67 Correct 83 ms 7800 KB Output is correct
68 Correct 89 ms 7032 KB Output is correct
69 Correct 21 ms 6144 KB Output is correct
70 Correct 42 ms 7040 KB Output is correct
71 Correct 84 ms 7672 KB Output is correct
72 Correct 75 ms 7672 KB Output is correct
73 Correct 14 ms 5760 KB Output is correct
74 Correct 44 ms 7168 KB Output is correct
75 Correct 67 ms 7672 KB Output is correct
76 Correct 32 ms 6656 KB Output is correct
77 Correct 72 ms 8184 KB Output is correct
78 Correct 17 ms 5760 KB Output is correct
79 Correct 43 ms 6656 KB Output is correct
80 Correct 30 ms 6656 KB Output is correct
81 Correct 76 ms 8316 KB Output is correct
82 Correct 8 ms 5376 KB Output is correct
83 Correct 39 ms 6656 KB Output is correct
84 Correct 68 ms 7544 KB Output is correct
85 Correct 8 ms 5248 KB Output is correct
86 Correct 53 ms 7544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4992 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Correct 16 ms 5760 KB Output is correct
4 Correct 15 ms 5760 KB Output is correct
5 Correct 14 ms 5760 KB Output is correct
6 Correct 14 ms 5760 KB Output is correct
7 Correct 18 ms 5760 KB Output is correct
8 Correct 6 ms 5248 KB Output is correct
9 Correct 3 ms 4992 KB Output is correct
10 Correct 6 ms 5248 KB Output is correct
11 Correct 14 ms 5760 KB Output is correct
12 Correct 14 ms 5760 KB Output is correct
13 Correct 4 ms 4992 KB Output is correct
14 Correct 14 ms 5760 KB Output is correct
15 Correct 4 ms 4992 KB Output is correct
16 Correct 14 ms 5760 KB Output is correct
17 Correct 3 ms 4992 KB Output is correct
18 Correct 14 ms 5760 KB Output is correct
19 Correct 6 ms 5248 KB Output is correct
20 Correct 9 ms 5504 KB Output is correct
21 Correct 9 ms 5504 KB Output is correct
22 Correct 6 ms 5248 KB Output is correct
23 Correct 18 ms 5888 KB Output is correct
24 Correct 6 ms 5248 KB Output is correct
25 Correct 18 ms 5888 KB Output is correct
26 Correct 17 ms 5888 KB Output is correct
27 Correct 16 ms 5760 KB Output is correct
28 Correct 16 ms 5888 KB Output is correct
29 Correct 13 ms 5760 KB Output is correct
30 Correct 22 ms 5888 KB Output is correct
31 Correct 18 ms 5888 KB Output is correct
32 Correct 19 ms 5888 KB Output is correct
33 Correct 17 ms 5888 KB Output is correct
34 Correct 18 ms 5888 KB Output is correct
35 Correct 10 ms 5504 KB Output is correct
36 Correct 10 ms 5504 KB Output is correct
37 Correct 10 ms 5504 KB Output is correct
38 Correct 8 ms 5376 KB Output is correct
39 Correct 8 ms 5248 KB Output is correct
40 Correct 24 ms 6272 KB Output is correct
41 Correct 9 ms 5376 KB Output is correct
42 Correct 24 ms 6272 KB Output is correct
43 Correct 24 ms 6272 KB Output is correct
44 Correct 3 ms 4992 KB Output is correct
45 Correct 477 ms 23452 KB Output is correct
46 Correct 213 ms 15352 KB Output is correct
47 Correct 477 ms 23288 KB Output is correct
48 Correct 507 ms 23288 KB Output is correct
49 Correct 134 ms 12924 KB Output is correct
50 Correct 479 ms 28536 KB Output is correct
51 Correct 458 ms 23288 KB Output is correct
52 Correct 127 ms 12664 KB Output is correct
53 Correct 130 ms 12792 KB Output is correct
54 Correct 30 ms 7424 KB Output is correct
55 Correct 484 ms 28552 KB Output is correct
56 Correct 72 ms 10104 KB Output is correct
57 Correct 125 ms 12792 KB Output is correct
58 Correct 173 ms 15352 KB Output is correct
59 Correct 72 ms 10104 KB Output is correct
60 Correct 73 ms 10104 KB Output is correct
61 Correct 176 ms 15352 KB Output is correct
62 Correct 126 ms 12664 KB Output is correct
63 Correct 248 ms 16632 KB Output is correct
64 Correct 73 ms 10104 KB Output is correct
65 Correct 321 ms 19320 KB Output is correct
66 Correct 119 ms 12664 KB Output is correct
67 Correct 247 ms 16744 KB Output is correct
68 Correct 340 ms 18684 KB Output is correct
69 Correct 347 ms 19320 KB Output is correct
70 Correct 133 ms 12664 KB Output is correct
71 Correct 316 ms 18728 KB Output is correct
72 Correct 243 ms 16248 KB Output is correct
73 Correct 404 ms 20984 KB Output is correct
74 Correct 137 ms 12664 KB Output is correct
75 Correct 125 ms 11384 KB Output is correct
76 Correct 259 ms 16248 KB Output is correct
77 Correct 410 ms 21084 KB Output is correct
78 Correct 177 ms 13048 KB Output is correct
79 Correct 124 ms 11384 KB Output is correct
80 Correct 66 ms 8184 KB Output is correct
81 Correct 173 ms 13016 KB Output is correct
82 Correct 279 ms 18040 KB Output is correct
83 Correct 74 ms 8184 KB Output is correct
84 Correct 276 ms 18040 KB Output is correct