Submission #145137

# Submission time Handle Problem Language Result Execution time Memory
145137 2019-08-18T21:26:34 Z tincamatei Political Development (BOI17_politicaldevelopment) C++14
100 / 100
704 ms 29076 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 50000;
const int MAX_K = 10;
set<int> graph[MAX_N];
set<pair<unsigned int, int> > nodes;
bool off[MAX_N];
int adj[MAX_K];

int bkt(int K) {
	int rez = 0;
	for(int i = 1; i < (1 << K); ++i) {
		int sz = 0;
		for(int j = 0; j < K; ++j)
			if((1 << j) & i) {
				++sz;
				if((i & adj[j]) != i)
					sz = -K;
			}

		rez = max(rez, sz);
	}
	return rez;
}

int maxclique(int nod) {
	vector<int> nodeset;
	
	int id = 0;
	for(auto it: graph[nod]) {
		nodeset.push_back(it);
		adj[id] = (1 << id);
		++id;
	}
	nodeset.push_back(nod);
	adj[id] = (1 << id);
	++id;

	for(int i = 0; i < id; ++i)
		for(int j = 0; j < id; ++j) {
			if(graph[nodeset[i]].find(nodeset[j]) != graph[nodeset[i]].end()) {
				adj[i] |= (1 << j);
				adj[j] |= (1 << i);
			}
		}
	
	return bkt(id);
}

int main() {
	int N, K;

	scanf("%d%d", &N, &K);
	for(int i = 0; i < N; ++i) {
		int d;
		scanf("%d", &d);
		for(int j = 0; j < d; ++j) {
			int x;
			scanf("%d", &x);
			graph[i].insert(x);
		}
		nodes.insert({graph[i].size(), i});
	}

	int rez = 0;
	while(!nodes.empty()) {
		int nod = (*nodes.begin()).second;
		rez = max(rez, maxclique(nod));
		off[nod] = true;
		nodes.erase(nodes.begin());
		for(auto it: graph[nod]) {
			if(!off[it]) {
				nodes.erase({graph[it].size(), it});
				graph[it].erase(nod);
				nodes.insert({graph[it].size(), it});
			}
		}
		graph[nod].clear();
	}

	printf("%d", rez);
	return 0;
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:55: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:58:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &d);
   ~~~~~^~~~~~~~~~
politicaldevelopment.cpp:61:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &x);
    ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2808 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 13 ms 3448 KB Output is correct
4 Correct 12 ms 3448 KB Output is correct
5 Correct 11 ms 3368 KB Output is correct
6 Correct 12 ms 3448 KB Output is correct
7 Correct 12 ms 3448 KB Output is correct
8 Correct 6 ms 2936 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 6 ms 2936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2808 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 13 ms 3448 KB Output is correct
4 Correct 12 ms 3448 KB Output is correct
5 Correct 11 ms 3368 KB Output is correct
6 Correct 12 ms 3448 KB Output is correct
7 Correct 12 ms 3448 KB Output is correct
8 Correct 6 ms 2936 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 6 ms 2936 KB Output is correct
11 Correct 11 ms 3448 KB Output is correct
12 Correct 11 ms 3448 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 11 ms 3448 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 13 ms 3448 KB Output is correct
17 Correct 5 ms 2680 KB Output is correct
18 Correct 12 ms 3444 KB Output is correct
19 Correct 7 ms 2936 KB Output is correct
20 Correct 9 ms 3192 KB Output is correct
21 Correct 9 ms 3192 KB Output is correct
22 Correct 6 ms 2936 KB Output is correct
23 Correct 14 ms 3576 KB Output is correct
24 Correct 7 ms 2936 KB Output is correct
25 Correct 14 ms 3576 KB Output is correct
26 Correct 14 ms 3448 KB Output is correct
27 Correct 11 ms 3448 KB Output is correct
28 Correct 13 ms 3576 KB Output is correct
29 Correct 12 ms 3448 KB Output is correct
30 Correct 17 ms 3576 KB Output is correct
31 Correct 14 ms 3576 KB Output is correct
32 Correct 15 ms 3576 KB Output is correct
33 Correct 14 ms 3576 KB Output is correct
34 Correct 14 ms 3580 KB Output is correct
35 Correct 10 ms 3192 KB Output is correct
36 Correct 9 ms 3192 KB Output is correct
37 Correct 9 ms 3192 KB Output is correct
38 Correct 8 ms 2936 KB Output is correct
39 Correct 7 ms 2936 KB Output is correct
40 Correct 21 ms 3992 KB Output is correct
41 Correct 7 ms 2936 KB Output is correct
42 Correct 19 ms 3960 KB Output is correct
43 Correct 20 ms 4088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2936 KB Output is correct
2 Correct 5 ms 2680 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
6 Correct 4 ms 2680 KB Output is correct
7 Correct 5 ms 2680 KB Output is correct
8 Correct 4 ms 2680 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
11 Correct 665 ms 28876 KB Output is correct
12 Correct 7 ms 2680 KB Output is correct
13 Correct 693 ms 28764 KB Output is correct
14 Correct 5 ms 2680 KB Output is correct
15 Correct 704 ms 29076 KB Output is correct
16 Correct 638 ms 28880 KB Output is correct
17 Correct 652 ms 28884 KB Output is correct
18 Correct 648 ms 28920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2808 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 13 ms 3448 KB Output is correct
4 Correct 12 ms 3448 KB Output is correct
5 Correct 11 ms 3368 KB Output is correct
6 Correct 12 ms 3448 KB Output is correct
7 Correct 12 ms 3448 KB Output is correct
8 Correct 6 ms 2936 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 6 ms 2936 KB Output is correct
11 Correct 11 ms 3448 KB Output is correct
12 Correct 11 ms 3448 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 11 ms 3448 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 13 ms 3448 KB Output is correct
17 Correct 5 ms 2680 KB Output is correct
18 Correct 12 ms 3444 KB Output is correct
19 Correct 7 ms 2936 KB Output is correct
20 Correct 9 ms 3192 KB Output is correct
21 Correct 9 ms 3192 KB Output is correct
22 Correct 6 ms 2936 KB Output is correct
23 Correct 14 ms 3576 KB Output is correct
24 Correct 7 ms 2936 KB Output is correct
25 Correct 14 ms 3576 KB Output is correct
26 Correct 14 ms 3448 KB Output is correct
27 Correct 11 ms 3448 KB Output is correct
28 Correct 13 ms 3576 KB Output is correct
29 Correct 12 ms 3448 KB Output is correct
30 Correct 17 ms 3576 KB Output is correct
31 Correct 14 ms 3576 KB Output is correct
32 Correct 15 ms 3576 KB Output is correct
33 Correct 14 ms 3576 KB Output is correct
34 Correct 14 ms 3580 KB Output is correct
35 Correct 10 ms 3192 KB Output is correct
36 Correct 9 ms 3192 KB Output is correct
37 Correct 9 ms 3192 KB Output is correct
38 Correct 8 ms 2936 KB Output is correct
39 Correct 7 ms 2936 KB Output is correct
40 Correct 21 ms 3992 KB Output is correct
41 Correct 7 ms 2936 KB Output is correct
42 Correct 19 ms 3960 KB Output is correct
43 Correct 20 ms 4088 KB Output is correct
44 Correct 55 ms 5112 KB Output is correct
45 Correct 4 ms 2680 KB Output is correct
46 Correct 22 ms 3932 KB Output is correct
47 Correct 39 ms 4984 KB Output is correct
48 Correct 19 ms 3960 KB Output is correct
49 Correct 39 ms 4984 KB Output is correct
50 Correct 39 ms 4984 KB Output is correct
51 Correct 199 ms 7032 KB Output is correct
52 Correct 12 ms 3448 KB Output is correct
53 Correct 331 ms 7544 KB Output is correct
54 Correct 358 ms 7544 KB Output is correct
55 Correct 13 ms 3448 KB Output is correct
56 Correct 11 ms 3448 KB Output is correct
57 Correct 6 ms 2936 KB Output is correct
58 Correct 332 ms 7672 KB Output is correct
59 Correct 15 ms 3960 KB Output is correct
60 Correct 12 ms 3452 KB Output is correct
61 Correct 16 ms 3960 KB Output is correct
62 Correct 15 ms 3960 KB Output is correct
63 Correct 55 ms 4984 KB Output is correct
64 Correct 40 ms 4728 KB Output is correct
65 Correct 18 ms 3836 KB Output is correct
66 Correct 15 ms 3960 KB Output is correct
67 Correct 58 ms 5368 KB Output is correct
68 Correct 37 ms 4728 KB Output is correct
69 Correct 18 ms 3832 KB Output is correct
70 Correct 33 ms 4732 KB Output is correct
71 Correct 56 ms 5368 KB Output is correct
72 Correct 54 ms 5376 KB Output is correct
73 Correct 11 ms 3448 KB Output is correct
74 Correct 37 ms 4728 KB Output is correct
75 Correct 49 ms 5368 KB Output is correct
76 Correct 25 ms 4344 KB Output is correct
77 Correct 90 ms 6008 KB Output is correct
78 Correct 11 ms 3476 KB Output is correct
79 Correct 49 ms 4344 KB Output is correct
80 Correct 25 ms 4216 KB Output is correct
81 Correct 98 ms 6008 KB Output is correct
82 Correct 8 ms 3064 KB Output is correct
83 Correct 46 ms 4216 KB Output is correct
84 Correct 51 ms 5288 KB Output is correct
85 Correct 8 ms 2892 KB Output is correct
86 Correct 55 ms 5240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2808 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 13 ms 3448 KB Output is correct
4 Correct 12 ms 3448 KB Output is correct
5 Correct 11 ms 3368 KB Output is correct
6 Correct 12 ms 3448 KB Output is correct
7 Correct 12 ms 3448 KB Output is correct
8 Correct 6 ms 2936 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 6 ms 2936 KB Output is correct
11 Correct 11 ms 3448 KB Output is correct
12 Correct 11 ms 3448 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 11 ms 3448 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 13 ms 3448 KB Output is correct
17 Correct 5 ms 2680 KB Output is correct
18 Correct 12 ms 3444 KB Output is correct
19 Correct 7 ms 2936 KB Output is correct
20 Correct 9 ms 3192 KB Output is correct
21 Correct 9 ms 3192 KB Output is correct
22 Correct 6 ms 2936 KB Output is correct
23 Correct 14 ms 3576 KB Output is correct
24 Correct 7 ms 2936 KB Output is correct
25 Correct 14 ms 3576 KB Output is correct
26 Correct 14 ms 3448 KB Output is correct
27 Correct 11 ms 3448 KB Output is correct
28 Correct 13 ms 3576 KB Output is correct
29 Correct 12 ms 3448 KB Output is correct
30 Correct 17 ms 3576 KB Output is correct
31 Correct 14 ms 3576 KB Output is correct
32 Correct 15 ms 3576 KB Output is correct
33 Correct 14 ms 3576 KB Output is correct
34 Correct 14 ms 3580 KB Output is correct
35 Correct 10 ms 3192 KB Output is correct
36 Correct 9 ms 3192 KB Output is correct
37 Correct 9 ms 3192 KB Output is correct
38 Correct 8 ms 2936 KB Output is correct
39 Correct 7 ms 2936 KB Output is correct
40 Correct 21 ms 3992 KB Output is correct
41 Correct 7 ms 2936 KB Output is correct
42 Correct 19 ms 3960 KB Output is correct
43 Correct 20 ms 4088 KB Output is correct
44 Correct 5 ms 2680 KB Output is correct
45 Correct 362 ms 21240 KB Output is correct
46 Correct 169 ms 13128 KB Output is correct
47 Correct 421 ms 20936 KB Output is correct
48 Correct 356 ms 20956 KB Output is correct
49 Correct 102 ms 10360 KB Output is correct
50 Correct 402 ms 26204 KB Output is correct
51 Correct 361 ms 20984 KB Output is correct
52 Correct 98 ms 10360 KB Output is correct
53 Correct 104 ms 10360 KB Output is correct
54 Correct 26 ms 5112 KB Output is correct
55 Correct 376 ms 26364 KB Output is correct
56 Correct 72 ms 7800 KB Output is correct
57 Correct 115 ms 10408 KB Output is correct
58 Correct 135 ms 13048 KB Output is correct
59 Correct 68 ms 7848 KB Output is correct
60 Correct 67 ms 7832 KB Output is correct
61 Correct 122 ms 13096 KB Output is correct
62 Correct 87 ms 10360 KB Output is correct
63 Correct 187 ms 14328 KB Output is correct
64 Correct 70 ms 7928 KB Output is correct
65 Correct 268 ms 17116 KB Output is correct
66 Correct 89 ms 10488 KB Output is correct
67 Correct 244 ms 14328 KB Output is correct
68 Correct 280 ms 16376 KB Output is correct
69 Correct 304 ms 17016 KB Output is correct
70 Correct 100 ms 10488 KB Output is correct
71 Correct 285 ms 16548 KB Output is correct
72 Correct 188 ms 14072 KB Output is correct
73 Correct 286 ms 18680 KB Output is correct
74 Correct 120 ms 10488 KB Output is correct
75 Correct 91 ms 9080 KB Output is correct
76 Correct 190 ms 14072 KB Output is correct
77 Correct 286 ms 18760 KB Output is correct
78 Correct 125 ms 10616 KB Output is correct
79 Correct 92 ms 8952 KB Output is correct
80 Correct 43 ms 5880 KB Output is correct
81 Correct 128 ms 10744 KB Output is correct
82 Correct 236 ms 15676 KB Output is correct
83 Correct 53 ms 5880 KB Output is correct
84 Correct 201 ms 15736 KB Output is correct