Submission #758476

# Submission time Handle Problem Language Result Execution time Memory
758476 2023-06-14T16:23:05 Z ByeWorld Political Development (BOI17_politicaldevelopment) C++14
100 / 100
1419 ms 33872 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ll long long
//#define int long long
using namespace std;
typedef pair<int,int> pii;
typedef pair<int, pii> ipii;
const int MAXN = 2e5+10;
const int INF = 1e9+10;
const int SQRT = 500;

int n, k;
int ans = 1;
int d[MAXN];
set <int> adj[MAXN];

class Compare {
    public:
       bool operator()(int a, int b){
           return d[a] > d[b];
      }
};
priority_queue <int, vector<int>, Compare> pq;

void solve(int nw){
	int deg = adj[nw].size();
	if(deg > 11){
		return;
	}

	vector <int> node;
	for(int i=0; i<(1<<deg); i++){//setiap bitmask
		node.clear(); //reset
		auto it = adj[nw].begin(); //idx 1

		for(int j=0; j<deg; j++){
			if(j!=0) it++;
			if((i>>j) & 1){//masuk ke mask
				node.pb(*it); //node neighbour
			}
		}

		bool can = 1;
		for(auto in : node){
			for(auto nei : node){
				if(in == nei) continue;
				if(adj[in].find(nei) == adj[in].end()) can = 0;
			}
		}
		if(can){
			//cout << nw << ' ' << node.size() << "upd\n";
			ans = max(ans, (int) node.size() + 1);
		}
	}
	for(auto in : adj[nw]){
		adj[in].erase(nw);
		d[in]--;
	}
}

signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n >> k;
	for(int i=1; i<=n; i++){
		cin >> d[i];
		for(int j=1; j<=d[i]; j++){
			int x; cin >> x; x++;
			adj[i].insert(x);
		}
		pq.push(i);
	}
	while(!pq.empty()){
		int nw = pq.top(); pq.pop();
		solve(nw);
	}

	cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 7 ms 9684 KB Output is correct
3 Correct 8 ms 10196 KB Output is correct
4 Correct 8 ms 10244 KB Output is correct
5 Correct 8 ms 10196 KB Output is correct
6 Correct 8 ms 10232 KB Output is correct
7 Correct 9 ms 10236 KB Output is correct
8 Correct 7 ms 9732 KB Output is correct
9 Correct 5 ms 9684 KB Output is correct
10 Correct 7 ms 9684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 7 ms 9684 KB Output is correct
3 Correct 8 ms 10196 KB Output is correct
4 Correct 8 ms 10244 KB Output is correct
5 Correct 8 ms 10196 KB Output is correct
6 Correct 8 ms 10232 KB Output is correct
7 Correct 9 ms 10236 KB Output is correct
8 Correct 7 ms 9732 KB Output is correct
9 Correct 5 ms 9684 KB Output is correct
10 Correct 7 ms 9684 KB Output is correct
11 Correct 10 ms 10324 KB Output is correct
12 Correct 8 ms 10248 KB Output is correct
13 Correct 5 ms 9724 KB Output is correct
14 Correct 8 ms 10280 KB Output is correct
15 Correct 5 ms 9620 KB Output is correct
16 Correct 9 ms 10244 KB Output is correct
17 Correct 5 ms 9720 KB Output is correct
18 Correct 8 ms 10240 KB Output is correct
19 Correct 6 ms 9772 KB Output is correct
20 Correct 7 ms 10032 KB Output is correct
21 Correct 6 ms 9988 KB Output is correct
22 Correct 6 ms 9728 KB Output is correct
23 Correct 9 ms 10324 KB Output is correct
24 Correct 6 ms 9684 KB Output is correct
25 Correct 9 ms 10372 KB Output is correct
26 Correct 8 ms 10324 KB Output is correct
27 Correct 8 ms 10196 KB Output is correct
28 Correct 8 ms 10324 KB Output is correct
29 Correct 8 ms 10236 KB Output is correct
30 Correct 11 ms 10376 KB Output is correct
31 Correct 9 ms 10460 KB Output is correct
32 Correct 11 ms 10380 KB Output is correct
33 Correct 10 ms 10452 KB Output is correct
34 Correct 13 ms 10452 KB Output is correct
35 Correct 7 ms 10068 KB Output is correct
36 Correct 8 ms 9988 KB Output is correct
37 Correct 7 ms 9984 KB Output is correct
38 Correct 6 ms 9856 KB Output is correct
39 Correct 8 ms 9972 KB Output is correct
40 Correct 11 ms 10708 KB Output is correct
41 Correct 6 ms 9896 KB Output is correct
42 Correct 11 ms 10708 KB Output is correct
43 Correct 12 ms 10708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 9776 KB Output is correct
2 Correct 7 ms 9684 KB Output is correct
3 Correct 5 ms 9684 KB Output is correct
4 Correct 5 ms 9720 KB Output is correct
5 Correct 6 ms 9716 KB Output is correct
6 Correct 5 ms 9684 KB Output is correct
7 Correct 6 ms 9684 KB Output is correct
8 Correct 6 ms 9716 KB Output is correct
9 Correct 7 ms 9684 KB Output is correct
10 Correct 5 ms 9684 KB Output is correct
11 Correct 1407 ms 33784 KB Output is correct
12 Correct 5 ms 9608 KB Output is correct
13 Correct 1322 ms 33864 KB Output is correct
14 Correct 7 ms 9684 KB Output is correct
15 Correct 1334 ms 33872 KB Output is correct
16 Correct 1345 ms 33788 KB Output is correct
17 Correct 1395 ms 33788 KB Output is correct
18 Correct 1419 ms 33816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 7 ms 9684 KB Output is correct
3 Correct 8 ms 10196 KB Output is correct
4 Correct 8 ms 10244 KB Output is correct
5 Correct 8 ms 10196 KB Output is correct
6 Correct 8 ms 10232 KB Output is correct
7 Correct 9 ms 10236 KB Output is correct
8 Correct 7 ms 9732 KB Output is correct
9 Correct 5 ms 9684 KB Output is correct
10 Correct 7 ms 9684 KB Output is correct
11 Correct 10 ms 10324 KB Output is correct
12 Correct 8 ms 10248 KB Output is correct
13 Correct 5 ms 9724 KB Output is correct
14 Correct 8 ms 10280 KB Output is correct
15 Correct 5 ms 9620 KB Output is correct
16 Correct 9 ms 10244 KB Output is correct
17 Correct 5 ms 9720 KB Output is correct
18 Correct 8 ms 10240 KB Output is correct
19 Correct 6 ms 9772 KB Output is correct
20 Correct 7 ms 10032 KB Output is correct
21 Correct 6 ms 9988 KB Output is correct
22 Correct 6 ms 9728 KB Output is correct
23 Correct 9 ms 10324 KB Output is correct
24 Correct 6 ms 9684 KB Output is correct
25 Correct 9 ms 10372 KB Output is correct
26 Correct 8 ms 10324 KB Output is correct
27 Correct 8 ms 10196 KB Output is correct
28 Correct 8 ms 10324 KB Output is correct
29 Correct 8 ms 10236 KB Output is correct
30 Correct 11 ms 10376 KB Output is correct
31 Correct 9 ms 10460 KB Output is correct
32 Correct 11 ms 10380 KB Output is correct
33 Correct 10 ms 10452 KB Output is correct
34 Correct 13 ms 10452 KB Output is correct
35 Correct 7 ms 10068 KB Output is correct
36 Correct 8 ms 9988 KB Output is correct
37 Correct 7 ms 9984 KB Output is correct
38 Correct 6 ms 9856 KB Output is correct
39 Correct 8 ms 9972 KB Output is correct
40 Correct 11 ms 10708 KB Output is correct
41 Correct 6 ms 9896 KB Output is correct
42 Correct 11 ms 10708 KB Output is correct
43 Correct 12 ms 10708 KB Output is correct
44 Correct 85 ms 11820 KB Output is correct
45 Correct 6 ms 9684 KB Output is correct
46 Correct 12 ms 10708 KB Output is correct
47 Correct 33 ms 11776 KB Output is correct
48 Correct 11 ms 10708 KB Output is correct
49 Correct 33 ms 11824 KB Output is correct
50 Correct 35 ms 11732 KB Output is correct
51 Correct 623 ms 13888 KB Output is correct
52 Correct 8 ms 10196 KB Output is correct
53 Correct 1211 ms 14396 KB Output is correct
54 Correct 1413 ms 14404 KB Output is correct
55 Correct 11 ms 10196 KB Output is correct
56 Correct 8 ms 10196 KB Output is correct
57 Correct 6 ms 9732 KB Output is correct
58 Correct 1187 ms 14392 KB Output is correct
59 Correct 11 ms 10708 KB Output is correct
60 Correct 8 ms 10196 KB Output is correct
61 Correct 15 ms 10692 KB Output is correct
62 Correct 11 ms 10708 KB Output is correct
63 Correct 80 ms 11788 KB Output is correct
64 Correct 45 ms 11496 KB Output is correct
65 Correct 11 ms 10580 KB Output is correct
66 Correct 11 ms 10808 KB Output is correct
67 Correct 97 ms 12260 KB Output is correct
68 Correct 58 ms 11476 KB Output is correct
69 Correct 11 ms 10632 KB Output is correct
70 Correct 29 ms 11604 KB Output is correct
71 Correct 89 ms 12212 KB Output is correct
72 Correct 77 ms 12248 KB Output is correct
73 Correct 8 ms 10196 KB Output is correct
74 Correct 32 ms 11648 KB Output is correct
75 Correct 80 ms 12116 KB Output is correct
76 Correct 22 ms 11144 KB Output is correct
77 Correct 261 ms 12712 KB Output is correct
78 Correct 8 ms 10236 KB Output is correct
79 Correct 132 ms 11200 KB Output is correct
80 Correct 16 ms 11092 KB Output is correct
81 Correct 263 ms 12728 KB Output is correct
82 Correct 7 ms 9864 KB Output is correct
83 Correct 130 ms 11220 KB Output is correct
84 Correct 144 ms 12080 KB Output is correct
85 Correct 8 ms 9980 KB Output is correct
86 Correct 132 ms 12080 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 7 ms 9684 KB Output is correct
3 Correct 8 ms 10196 KB Output is correct
4 Correct 8 ms 10244 KB Output is correct
5 Correct 8 ms 10196 KB Output is correct
6 Correct 8 ms 10232 KB Output is correct
7 Correct 9 ms 10236 KB Output is correct
8 Correct 7 ms 9732 KB Output is correct
9 Correct 5 ms 9684 KB Output is correct
10 Correct 7 ms 9684 KB Output is correct
11 Correct 10 ms 10324 KB Output is correct
12 Correct 8 ms 10248 KB Output is correct
13 Correct 5 ms 9724 KB Output is correct
14 Correct 8 ms 10280 KB Output is correct
15 Correct 5 ms 9620 KB Output is correct
16 Correct 9 ms 10244 KB Output is correct
17 Correct 5 ms 9720 KB Output is correct
18 Correct 8 ms 10240 KB Output is correct
19 Correct 6 ms 9772 KB Output is correct
20 Correct 7 ms 10032 KB Output is correct
21 Correct 6 ms 9988 KB Output is correct
22 Correct 6 ms 9728 KB Output is correct
23 Correct 9 ms 10324 KB Output is correct
24 Correct 6 ms 9684 KB Output is correct
25 Correct 9 ms 10372 KB Output is correct
26 Correct 8 ms 10324 KB Output is correct
27 Correct 8 ms 10196 KB Output is correct
28 Correct 8 ms 10324 KB Output is correct
29 Correct 8 ms 10236 KB Output is correct
30 Correct 11 ms 10376 KB Output is correct
31 Correct 9 ms 10460 KB Output is correct
32 Correct 11 ms 10380 KB Output is correct
33 Correct 10 ms 10452 KB Output is correct
34 Correct 13 ms 10452 KB Output is correct
35 Correct 7 ms 10068 KB Output is correct
36 Correct 8 ms 9988 KB Output is correct
37 Correct 7 ms 9984 KB Output is correct
38 Correct 6 ms 9856 KB Output is correct
39 Correct 8 ms 9972 KB Output is correct
40 Correct 11 ms 10708 KB Output is correct
41 Correct 6 ms 9896 KB Output is correct
42 Correct 11 ms 10708 KB Output is correct
43 Correct 12 ms 10708 KB Output is correct
44 Correct 5 ms 9684 KB Output is correct
45 Correct 135 ms 25980 KB Output is correct
46 Correct 58 ms 18032 KB Output is correct
47 Correct 141 ms 25888 KB Output is correct
48 Correct 130 ms 25960 KB Output is correct
49 Correct 53 ms 15432 KB Output is correct
50 Correct 284 ms 31128 KB Output is correct
51 Correct 145 ms 25856 KB Output is correct
52 Correct 35 ms 15440 KB Output is correct
53 Correct 38 ms 15480 KB Output is correct
54 Correct 13 ms 10248 KB Output is correct
55 Correct 217 ms 31148 KB Output is correct
56 Correct 22 ms 12828 KB Output is correct
57 Correct 36 ms 15388 KB Output is correct
58 Correct 50 ms 17980 KB Output is correct
59 Correct 23 ms 12752 KB Output is correct
60 Correct 25 ms 12796 KB Output is correct
61 Correct 55 ms 17996 KB Output is correct
62 Correct 35 ms 15388 KB Output is correct
63 Correct 62 ms 19320 KB Output is correct
64 Correct 23 ms 12800 KB Output is correct
65 Correct 94 ms 21992 KB Output is correct
66 Correct 40 ms 15400 KB Output is correct
67 Correct 69 ms 19380 KB Output is correct
68 Correct 86 ms 21320 KB Output is correct
69 Correct 109 ms 21924 KB Output is correct
70 Correct 37 ms 15432 KB Output is correct
71 Correct 90 ms 21348 KB Output is correct
72 Correct 80 ms 18956 KB Output is correct
73 Correct 122 ms 23672 KB Output is correct
74 Correct 39 ms 15436 KB Output is correct
75 Correct 37 ms 15020 KB Output is correct
76 Correct 74 ms 18932 KB Output is correct
77 Correct 121 ms 23684 KB Output is correct
78 Correct 64 ms 16664 KB Output is correct
79 Correct 37 ms 15016 KB Output is correct
80 Correct 22 ms 12296 KB Output is correct
81 Correct 62 ms 16596 KB Output is correct
82 Correct 78 ms 20616 KB Output is correct
83 Correct 20 ms 12332 KB Output is correct
84 Correct 84 ms 20636 KB Output is correct