답안 #235085

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
235085 2020-05-27T01:07:09 Z luciocf Political Development (BOI17_politicaldevelopment) C++14
100 / 100
1004 ms 52472 KB
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;

const int maxn = 5e4+10;

int n, k;

set<int> grafo[maxn], grafo_rev[maxn];

int main(void)
{
	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 v;
			scanf("%d", &v);

			grafo[i].insert(v);
			grafo_rev[v].insert(i);
		}
	}

	set<pii> st;

	for (int i = 0; i < n; i++)
		st.insert({grafo[i].size(), i});

	int ans = 0;

	while (st.size())
	{
		int u = st.begin()->second;
		st.erase(st.begin());

		vector<int> V;
		for (auto v: grafo[u])
			V.push_back(v);

		for (int mask = 0; mask < 1<<((int)V.size()); mask++)
		{
			bool ok = 1;

			for (int i = 0; i < (int)V.size(); i++)
			{
				if (!(mask&(1<<i))) continue;

				for (int j = 0; j < (int)V.size(); j++)
				{
					if (i == j || !(mask&(1<<j))) continue;

					if (grafo[V[i]].find(V[j]) == grafo[V[i]].end())
					{
						ok = 0;
						break;
					}
				}

				if (!ok) break;
			}

			if (ok) ans = max(ans, __builtin_popcount(mask));
		}

		for (auto v: grafo_rev[u])
		{
			if (st.find({grafo[v].size(), v}) == st.end()) continue;

			st.erase({grafo[v].size(), v});

			grafo[v].erase(u);

			st.insert({grafo[v].size(), v});
		}
	}

	printf("%d\n", ans+1);
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:15: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:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &d);
   ~~~~~^~~~~~~~~~
politicaldevelopment.cpp:25:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &v);
    ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4992 KB Output is correct
2 Correct 7 ms 4992 KB Output is correct
3 Correct 16 ms 6272 KB Output is correct
4 Correct 14 ms 6144 KB Output is correct
5 Correct 16 ms 6144 KB Output is correct
6 Correct 16 ms 6144 KB Output is correct
7 Correct 16 ms 6144 KB Output is correct
8 Correct 8 ms 5248 KB Output is correct
9 Correct 7 ms 4992 KB Output is correct
10 Correct 8 ms 5248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4992 KB Output is correct
2 Correct 7 ms 4992 KB Output is correct
3 Correct 16 ms 6272 KB Output is correct
4 Correct 14 ms 6144 KB Output is correct
5 Correct 16 ms 6144 KB Output is correct
6 Correct 16 ms 6144 KB Output is correct
7 Correct 16 ms 6144 KB Output is correct
8 Correct 8 ms 5248 KB Output is correct
9 Correct 7 ms 4992 KB Output is correct
10 Correct 8 ms 5248 KB Output is correct
11 Correct 14 ms 6144 KB Output is correct
12 Correct 14 ms 6144 KB Output is correct
13 Correct 7 ms 4992 KB Output is correct
14 Correct 15 ms 6376 KB Output is correct
15 Correct 7 ms 5120 KB Output is correct
16 Correct 15 ms 6272 KB Output is correct
17 Correct 8 ms 4992 KB Output is correct
18 Correct 16 ms 6272 KB Output is correct
19 Correct 10 ms 5248 KB Output is correct
20 Correct 12 ms 5760 KB Output is correct
21 Correct 11 ms 5760 KB Output is correct
22 Correct 8 ms 5248 KB Output is correct
23 Correct 19 ms 6528 KB Output is correct
24 Correct 8 ms 5248 KB Output is correct
25 Correct 18 ms 6528 KB Output is correct
26 Correct 19 ms 6528 KB Output is correct
27 Correct 14 ms 6272 KB Output is correct
28 Correct 16 ms 6400 KB Output is correct
29 Correct 14 ms 6272 KB Output is correct
30 Correct 17 ms 6528 KB Output is correct
31 Correct 26 ms 6528 KB Output is correct
32 Correct 21 ms 6528 KB Output is correct
33 Correct 17 ms 6528 KB Output is correct
34 Correct 20 ms 6528 KB Output is correct
35 Correct 12 ms 5760 KB Output is correct
36 Correct 12 ms 5760 KB Output is correct
37 Correct 13 ms 5760 KB Output is correct
38 Correct 11 ms 5504 KB Output is correct
39 Correct 11 ms 5504 KB Output is correct
40 Correct 26 ms 7168 KB Output is correct
41 Correct 11 ms 5504 KB Output is correct
42 Correct 28 ms 7296 KB Output is correct
43 Correct 25 ms 7168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 5248 KB Output is correct
2 Correct 7 ms 4992 KB Output is correct
3 Correct 7 ms 4992 KB Output is correct
4 Correct 7 ms 4992 KB Output is correct
5 Correct 7 ms 4992 KB Output is correct
6 Correct 7 ms 4992 KB Output is correct
7 Correct 7 ms 4992 KB Output is correct
8 Correct 8 ms 4992 KB Output is correct
9 Correct 7 ms 4992 KB Output is correct
10 Correct 7 ms 4992 KB Output is correct
11 Correct 988 ms 52472 KB Output is correct
12 Correct 7 ms 4992 KB Output is correct
13 Correct 1004 ms 52344 KB Output is correct
14 Correct 7 ms 4992 KB Output is correct
15 Correct 984 ms 52216 KB Output is correct
16 Correct 979 ms 52460 KB Output is correct
17 Correct 983 ms 52344 KB Output is correct
18 Correct 978 ms 52344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4992 KB Output is correct
2 Correct 7 ms 4992 KB Output is correct
3 Correct 16 ms 6272 KB Output is correct
4 Correct 14 ms 6144 KB Output is correct
5 Correct 16 ms 6144 KB Output is correct
6 Correct 16 ms 6144 KB Output is correct
7 Correct 16 ms 6144 KB Output is correct
8 Correct 8 ms 5248 KB Output is correct
9 Correct 7 ms 4992 KB Output is correct
10 Correct 8 ms 5248 KB Output is correct
11 Correct 14 ms 6144 KB Output is correct
12 Correct 14 ms 6144 KB Output is correct
13 Correct 7 ms 4992 KB Output is correct
14 Correct 15 ms 6376 KB Output is correct
15 Correct 7 ms 5120 KB Output is correct
16 Correct 15 ms 6272 KB Output is correct
17 Correct 8 ms 4992 KB Output is correct
18 Correct 16 ms 6272 KB Output is correct
19 Correct 10 ms 5248 KB Output is correct
20 Correct 12 ms 5760 KB Output is correct
21 Correct 11 ms 5760 KB Output is correct
22 Correct 8 ms 5248 KB Output is correct
23 Correct 19 ms 6528 KB Output is correct
24 Correct 8 ms 5248 KB Output is correct
25 Correct 18 ms 6528 KB Output is correct
26 Correct 19 ms 6528 KB Output is correct
27 Correct 14 ms 6272 KB Output is correct
28 Correct 16 ms 6400 KB Output is correct
29 Correct 14 ms 6272 KB Output is correct
30 Correct 17 ms 6528 KB Output is correct
31 Correct 26 ms 6528 KB Output is correct
32 Correct 21 ms 6528 KB Output is correct
33 Correct 17 ms 6528 KB Output is correct
34 Correct 20 ms 6528 KB Output is correct
35 Correct 12 ms 5760 KB Output is correct
36 Correct 12 ms 5760 KB Output is correct
37 Correct 13 ms 5760 KB Output is correct
38 Correct 11 ms 5504 KB Output is correct
39 Correct 11 ms 5504 KB Output is correct
40 Correct 26 ms 7168 KB Output is correct
41 Correct 11 ms 5504 KB Output is correct
42 Correct 28 ms 7296 KB Output is correct
43 Correct 25 ms 7168 KB Output is correct
44 Correct 115 ms 9216 KB Output is correct
45 Correct 7 ms 4992 KB Output is correct
46 Correct 25 ms 7168 KB Output is correct
47 Correct 55 ms 9208 KB Output is correct
48 Correct 24 ms 7260 KB Output is correct
49 Correct 48 ms 9216 KB Output is correct
50 Correct 46 ms 9088 KB Output is correct
51 Correct 143 ms 13176 KB Output is correct
52 Correct 15 ms 6272 KB Output is correct
53 Correct 143 ms 14304 KB Output is correct
54 Correct 184 ms 14200 KB Output is correct
55 Correct 15 ms 6272 KB Output is correct
56 Correct 14 ms 6272 KB Output is correct
57 Correct 8 ms 5248 KB Output is correct
58 Correct 144 ms 14072 KB Output is correct
59 Correct 21 ms 7168 KB Output is correct
60 Correct 15 ms 6272 KB Output is correct
61 Correct 22 ms 7168 KB Output is correct
62 Correct 21 ms 7168 KB Output is correct
63 Correct 116 ms 9216 KB Output is correct
64 Correct 67 ms 8788 KB Output is correct
65 Correct 22 ms 6912 KB Output is correct
66 Correct 21 ms 7296 KB Output is correct
67 Correct 83 ms 10104 KB Output is correct
68 Correct 67 ms 8704 KB Output is correct
69 Correct 22 ms 6912 KB Output is correct
70 Correct 42 ms 8832 KB Output is correct
71 Correct 78 ms 9896 KB Output is correct
72 Correct 66 ms 9856 KB Output is correct
73 Correct 17 ms 6272 KB Output is correct
74 Correct 43 ms 8832 KB Output is correct
75 Correct 65 ms 9856 KB Output is correct
76 Correct 30 ms 7936 KB Output is correct
77 Correct 89 ms 10872 KB Output is correct
78 Correct 14 ms 6272 KB Output is correct
79 Correct 39 ms 7936 KB Output is correct
80 Correct 32 ms 7936 KB Output is correct
81 Correct 81 ms 10872 KB Output is correct
82 Correct 11 ms 5504 KB Output is correct
83 Correct 39 ms 7936 KB Output is correct
84 Correct 54 ms 9808 KB Output is correct
85 Correct 11 ms 5504 KB Output is correct
86 Correct 55 ms 9720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4992 KB Output is correct
2 Correct 7 ms 4992 KB Output is correct
3 Correct 16 ms 6272 KB Output is correct
4 Correct 14 ms 6144 KB Output is correct
5 Correct 16 ms 6144 KB Output is correct
6 Correct 16 ms 6144 KB Output is correct
7 Correct 16 ms 6144 KB Output is correct
8 Correct 8 ms 5248 KB Output is correct
9 Correct 7 ms 4992 KB Output is correct
10 Correct 8 ms 5248 KB Output is correct
11 Correct 14 ms 6144 KB Output is correct
12 Correct 14 ms 6144 KB Output is correct
13 Correct 7 ms 4992 KB Output is correct
14 Correct 15 ms 6376 KB Output is correct
15 Correct 7 ms 5120 KB Output is correct
16 Correct 15 ms 6272 KB Output is correct
17 Correct 8 ms 4992 KB Output is correct
18 Correct 16 ms 6272 KB Output is correct
19 Correct 10 ms 5248 KB Output is correct
20 Correct 12 ms 5760 KB Output is correct
21 Correct 11 ms 5760 KB Output is correct
22 Correct 8 ms 5248 KB Output is correct
23 Correct 19 ms 6528 KB Output is correct
24 Correct 8 ms 5248 KB Output is correct
25 Correct 18 ms 6528 KB Output is correct
26 Correct 19 ms 6528 KB Output is correct
27 Correct 14 ms 6272 KB Output is correct
28 Correct 16 ms 6400 KB Output is correct
29 Correct 14 ms 6272 KB Output is correct
30 Correct 17 ms 6528 KB Output is correct
31 Correct 26 ms 6528 KB Output is correct
32 Correct 21 ms 6528 KB Output is correct
33 Correct 17 ms 6528 KB Output is correct
34 Correct 20 ms 6528 KB Output is correct
35 Correct 12 ms 5760 KB Output is correct
36 Correct 12 ms 5760 KB Output is correct
37 Correct 13 ms 5760 KB Output is correct
38 Correct 11 ms 5504 KB Output is correct
39 Correct 11 ms 5504 KB Output is correct
40 Correct 26 ms 7168 KB Output is correct
41 Correct 11 ms 5504 KB Output is correct
42 Correct 28 ms 7296 KB Output is correct
43 Correct 25 ms 7168 KB Output is correct
44 Correct 7 ms 4992 KB Output is correct
45 Correct 563 ms 37532 KB Output is correct
46 Correct 208 ms 22440 KB Output is correct
47 Correct 560 ms 37496 KB Output is correct
48 Correct 552 ms 37368 KB Output is correct
49 Correct 116 ms 17400 KB Output is correct
50 Correct 430 ms 47224 KB Output is correct
51 Correct 569 ms 37624 KB Output is correct
52 Correct 122 ms 17400 KB Output is correct
53 Correct 111 ms 17400 KB Output is correct
54 Correct 24 ms 7424 KB Output is correct
55 Correct 448 ms 47224 KB Output is correct
56 Correct 70 ms 12408 KB Output is correct
57 Correct 126 ms 17712 KB Output is correct
58 Correct 170 ms 22520 KB Output is correct
59 Correct 69 ms 12408 KB Output is correct
60 Correct 69 ms 12408 KB Output is correct
61 Correct 168 ms 22392 KB Output is correct
62 Correct 114 ms 17400 KB Output is correct
63 Correct 284 ms 25080 KB Output is correct
64 Correct 69 ms 12408 KB Output is correct
65 Correct 369 ms 30072 KB Output is correct
66 Correct 111 ms 17400 KB Output is correct
67 Correct 273 ms 24824 KB Output is correct
68 Correct 362 ms 28716 KB Output is correct
69 Correct 380 ms 29944 KB Output is correct
70 Correct 123 ms 17400 KB Output is correct
71 Correct 367 ms 28664 KB Output is correct
72 Correct 248 ms 24056 KB Output is correct
73 Correct 442 ms 33016 KB Output is correct
74 Correct 131 ms 17400 KB Output is correct
75 Correct 131 ms 15864 KB Output is correct
76 Correct 241 ms 24184 KB Output is correct
77 Correct 438 ms 33144 KB Output is correct
78 Correct 190 ms 19064 KB Output is correct
79 Correct 129 ms 15864 KB Output is correct
80 Correct 56 ms 10488 KB Output is correct
81 Correct 185 ms 19064 KB Output is correct
82 Correct 329 ms 27384 KB Output is correct
83 Correct 53 ms 10496 KB Output is correct
84 Correct 315 ms 27512 KB Output is correct