답안 #727241

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
727241 2023-04-20T09:42:17 Z gagik_2007 Political Development (BOI17_politicaldevelopment) C++17
100 / 100
664 ms 60492 KB
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <chrono>
#include <ctime>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <limits>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <functional>
#include <random>
#include <cassert>
using namespace std;

typedef long long ll;
typedef long double ld;

#define ff first
#define ss second

ll ttt;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ll N = 500007;
ll n, m, k;
vector<int>g[N];
int deg[N];
bool used[N];
unordered_map<ll, bool>d;
int vs[N];

ll value(int v, int u) {
	return v * N + u;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> m;
		deg[i] = m;
		for (int j = 0; j < m; j++) {
			int x;
			cin >> x;
			g[i].push_back(x);
			d[value(i, x)] = true;
		}
	}
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>q;
	for (int v = 0; v < n; v++) {
		q.push({ deg[v],v });
	}
	ll ans = 0;
	while (!q.empty()) {
		int v = q.top().ss;
		q.pop();
		//cout << v << ": " << deg[v] << endl;
		if (!used[v]) {
			int ind = 0;
			for (int i = 0; i < g[v].size(); i++) {
				if (!used[g[v][i]]) {
					vs[ind] = g[v][i];
					ind++;
				}
			}
			for (int msk = 0; msk < (1 << deg[v]); msk++) {
				ll cnt = 1;
				bool ok = true;
				for (int i = 0; i < deg[v]; i++) {
					if (msk & (1 << i)) {
						cnt++;
					}
					for (int j = i + 1; j < deg[v]; j++) {
						if (msk & (1 << j)) {
							if (!d[value(vs[i], vs[j])]) {
								ok = false;
								break;
							}
						}
					}
				}
				if (ok) {
					ans = max(ans, cnt);
				}
			}
			used[v] = true;
			for (int u : g[v]) {
				deg[u]--;
				q.push({ deg[u],u });
			}
		}
	}
	cout << ans << endl;
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:70:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |    for (int i = 0; i < g[v].size(); i++) {
      |                    ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 11988 KB Output is correct
2 Correct 7 ms 12012 KB Output is correct
3 Correct 11 ms 12724 KB Output is correct
4 Correct 10 ms 12884 KB Output is correct
5 Correct 10 ms 12884 KB Output is correct
6 Correct 10 ms 12864 KB Output is correct
7 Correct 11 ms 12856 KB Output is correct
8 Correct 9 ms 12116 KB Output is correct
9 Correct 7 ms 12080 KB Output is correct
10 Correct 8 ms 12116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 11988 KB Output is correct
2 Correct 7 ms 12012 KB Output is correct
3 Correct 11 ms 12724 KB Output is correct
4 Correct 10 ms 12884 KB Output is correct
5 Correct 10 ms 12884 KB Output is correct
6 Correct 10 ms 12864 KB Output is correct
7 Correct 11 ms 12856 KB Output is correct
8 Correct 9 ms 12116 KB Output is correct
9 Correct 7 ms 12080 KB Output is correct
10 Correct 8 ms 12116 KB Output is correct
11 Correct 10 ms 12964 KB Output is correct
12 Correct 10 ms 12884 KB Output is correct
13 Correct 7 ms 11988 KB Output is correct
14 Correct 11 ms 12884 KB Output is correct
15 Correct 8 ms 12072 KB Output is correct
16 Correct 11 ms 12756 KB Output is correct
17 Correct 8 ms 11988 KB Output is correct
18 Correct 11 ms 12856 KB Output is correct
19 Correct 8 ms 12212 KB Output is correct
20 Correct 9 ms 12596 KB Output is correct
21 Correct 10 ms 12628 KB Output is correct
22 Correct 7 ms 12220 KB Output is correct
23 Correct 13 ms 13012 KB Output is correct
24 Correct 8 ms 12116 KB Output is correct
25 Correct 12 ms 13020 KB Output is correct
26 Correct 11 ms 12856 KB Output is correct
27 Correct 11 ms 12748 KB Output is correct
28 Correct 12 ms 12884 KB Output is correct
29 Correct 11 ms 12756 KB Output is correct
30 Correct 13 ms 13048 KB Output is correct
31 Correct 14 ms 12984 KB Output is correct
32 Correct 12 ms 13016 KB Output is correct
33 Correct 12 ms 13012 KB Output is correct
34 Correct 13 ms 13012 KB Output is correct
35 Correct 9 ms 12500 KB Output is correct
36 Correct 9 ms 12468 KB Output is correct
37 Correct 10 ms 12500 KB Output is correct
38 Correct 9 ms 12480 KB Output is correct
39 Correct 9 ms 12468 KB Output is correct
40 Correct 17 ms 13616 KB Output is correct
41 Correct 11 ms 12372 KB Output is correct
42 Correct 18 ms 13736 KB Output is correct
43 Correct 16 ms 13616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 12136 KB Output is correct
2 Correct 7 ms 11988 KB Output is correct
3 Correct 6 ms 12072 KB Output is correct
4 Correct 6 ms 12024 KB Output is correct
5 Correct 7 ms 11988 KB Output is correct
6 Correct 7 ms 11972 KB Output is correct
7 Correct 6 ms 11988 KB Output is correct
8 Correct 9 ms 12048 KB Output is correct
9 Correct 6 ms 11988 KB Output is correct
10 Correct 7 ms 12076 KB Output is correct
11 Correct 624 ms 60232 KB Output is correct
12 Correct 7 ms 11988 KB Output is correct
13 Correct 625 ms 60308 KB Output is correct
14 Correct 7 ms 11988 KB Output is correct
15 Correct 625 ms 60492 KB Output is correct
16 Correct 651 ms 60192 KB Output is correct
17 Correct 645 ms 60216 KB Output is correct
18 Correct 664 ms 60268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 11988 KB Output is correct
2 Correct 7 ms 12012 KB Output is correct
3 Correct 11 ms 12724 KB Output is correct
4 Correct 10 ms 12884 KB Output is correct
5 Correct 10 ms 12884 KB Output is correct
6 Correct 10 ms 12864 KB Output is correct
7 Correct 11 ms 12856 KB Output is correct
8 Correct 9 ms 12116 KB Output is correct
9 Correct 7 ms 12080 KB Output is correct
10 Correct 8 ms 12116 KB Output is correct
11 Correct 10 ms 12964 KB Output is correct
12 Correct 10 ms 12884 KB Output is correct
13 Correct 7 ms 11988 KB Output is correct
14 Correct 11 ms 12884 KB Output is correct
15 Correct 8 ms 12072 KB Output is correct
16 Correct 11 ms 12756 KB Output is correct
17 Correct 8 ms 11988 KB Output is correct
18 Correct 11 ms 12856 KB Output is correct
19 Correct 8 ms 12212 KB Output is correct
20 Correct 9 ms 12596 KB Output is correct
21 Correct 10 ms 12628 KB Output is correct
22 Correct 7 ms 12220 KB Output is correct
23 Correct 13 ms 13012 KB Output is correct
24 Correct 8 ms 12116 KB Output is correct
25 Correct 12 ms 13020 KB Output is correct
26 Correct 11 ms 12856 KB Output is correct
27 Correct 11 ms 12748 KB Output is correct
28 Correct 12 ms 12884 KB Output is correct
29 Correct 11 ms 12756 KB Output is correct
30 Correct 13 ms 13048 KB Output is correct
31 Correct 14 ms 12984 KB Output is correct
32 Correct 12 ms 13016 KB Output is correct
33 Correct 12 ms 13012 KB Output is correct
34 Correct 13 ms 13012 KB Output is correct
35 Correct 9 ms 12500 KB Output is correct
36 Correct 9 ms 12468 KB Output is correct
37 Correct 10 ms 12500 KB Output is correct
38 Correct 9 ms 12480 KB Output is correct
39 Correct 9 ms 12468 KB Output is correct
40 Correct 17 ms 13616 KB Output is correct
41 Correct 11 ms 12372 KB Output is correct
42 Correct 18 ms 13736 KB Output is correct
43 Correct 16 ms 13616 KB Output is correct
44 Correct 71 ms 14128 KB Output is correct
45 Correct 7 ms 12000 KB Output is correct
46 Correct 16 ms 13616 KB Output is correct
47 Correct 32 ms 15580 KB Output is correct
48 Correct 15 ms 13616 KB Output is correct
49 Correct 29 ms 15604 KB Output is correct
50 Correct 29 ms 15600 KB Output is correct
51 Correct 162 ms 22868 KB Output is correct
52 Correct 10 ms 12884 KB Output is correct
53 Correct 239 ms 18240 KB Output is correct
54 Correct 296 ms 24552 KB Output is correct
55 Correct 11 ms 12756 KB Output is correct
56 Correct 10 ms 12884 KB Output is correct
57 Correct 7 ms 12208 KB Output is correct
58 Correct 234 ms 18188 KB Output is correct
59 Correct 15 ms 13260 KB Output is correct
60 Correct 11 ms 12756 KB Output is correct
61 Correct 15 ms 13268 KB Output is correct
62 Correct 15 ms 13268 KB Output is correct
63 Correct 75 ms 14204 KB Output is correct
64 Correct 43 ms 14120 KB Output is correct
65 Correct 15 ms 13652 KB Output is correct
66 Correct 15 ms 13268 KB Output is correct
67 Correct 58 ms 17456 KB Output is correct
68 Correct 44 ms 13960 KB Output is correct
69 Correct 14 ms 13268 KB Output is correct
70 Correct 29 ms 15204 KB Output is correct
71 Correct 51 ms 17496 KB Output is correct
72 Correct 47 ms 16092 KB Output is correct
73 Correct 11 ms 12756 KB Output is correct
74 Correct 27 ms 15220 KB Output is correct
75 Correct 49 ms 17472 KB Output is correct
76 Correct 19 ms 14060 KB Output is correct
77 Correct 84 ms 18496 KB Output is correct
78 Correct 11 ms 12752 KB Output is correct
79 Correct 40 ms 15184 KB Output is correct
80 Correct 18 ms 14032 KB Output is correct
81 Correct 82 ms 18492 KB Output is correct
82 Correct 9 ms 12472 KB Output is correct
83 Correct 43 ms 15284 KB Output is correct
84 Correct 40 ms 17512 KB Output is correct
85 Correct 9 ms 12372 KB Output is correct
86 Correct 49 ms 17460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 11988 KB Output is correct
2 Correct 7 ms 12012 KB Output is correct
3 Correct 11 ms 12724 KB Output is correct
4 Correct 10 ms 12884 KB Output is correct
5 Correct 10 ms 12884 KB Output is correct
6 Correct 10 ms 12864 KB Output is correct
7 Correct 11 ms 12856 KB Output is correct
8 Correct 9 ms 12116 KB Output is correct
9 Correct 7 ms 12080 KB Output is correct
10 Correct 8 ms 12116 KB Output is correct
11 Correct 10 ms 12964 KB Output is correct
12 Correct 10 ms 12884 KB Output is correct
13 Correct 7 ms 11988 KB Output is correct
14 Correct 11 ms 12884 KB Output is correct
15 Correct 8 ms 12072 KB Output is correct
16 Correct 11 ms 12756 KB Output is correct
17 Correct 8 ms 11988 KB Output is correct
18 Correct 11 ms 12856 KB Output is correct
19 Correct 8 ms 12212 KB Output is correct
20 Correct 9 ms 12596 KB Output is correct
21 Correct 10 ms 12628 KB Output is correct
22 Correct 7 ms 12220 KB Output is correct
23 Correct 13 ms 13012 KB Output is correct
24 Correct 8 ms 12116 KB Output is correct
25 Correct 12 ms 13020 KB Output is correct
26 Correct 11 ms 12856 KB Output is correct
27 Correct 11 ms 12748 KB Output is correct
28 Correct 12 ms 12884 KB Output is correct
29 Correct 11 ms 12756 KB Output is correct
30 Correct 13 ms 13048 KB Output is correct
31 Correct 14 ms 12984 KB Output is correct
32 Correct 12 ms 13016 KB Output is correct
33 Correct 12 ms 13012 KB Output is correct
34 Correct 13 ms 13012 KB Output is correct
35 Correct 9 ms 12500 KB Output is correct
36 Correct 9 ms 12468 KB Output is correct
37 Correct 10 ms 12500 KB Output is correct
38 Correct 9 ms 12480 KB Output is correct
39 Correct 9 ms 12468 KB Output is correct
40 Correct 17 ms 13616 KB Output is correct
41 Correct 11 ms 12372 KB Output is correct
42 Correct 18 ms 13736 KB Output is correct
43 Correct 16 ms 13616 KB Output is correct
44 Correct 6 ms 11988 KB Output is correct
45 Correct 267 ms 37416 KB Output is correct
46 Correct 110 ms 22700 KB Output is correct
47 Correct 313 ms 37884 KB Output is correct
48 Correct 277 ms 37388 KB Output is correct
49 Correct 60 ms 20980 KB Output is correct
50 Correct 256 ms 39092 KB Output is correct
51 Correct 288 ms 37744 KB Output is correct
52 Correct 61 ms 20104 KB Output is correct
53 Correct 58 ms 21176 KB Output is correct
54 Correct 14 ms 12984 KB Output is correct
55 Correct 251 ms 39156 KB Output is correct
56 Correct 43 ms 17372 KB Output is correct
57 Correct 52 ms 20120 KB Output is correct
58 Correct 104 ms 21784 KB Output is correct
59 Correct 40 ms 17396 KB Output is correct
60 Correct 36 ms 17380 KB Output is correct
61 Correct 82 ms 21700 KB Output is correct
62 Correct 73 ms 19896 KB Output is correct
63 Correct 142 ms 25028 KB Output is correct
64 Correct 45 ms 17520 KB Output is correct
65 Correct 181 ms 28480 KB Output is correct
66 Correct 73 ms 19944 KB Output is correct
67 Correct 133 ms 25056 KB Output is correct
68 Correct 155 ms 27648 KB Output is correct
69 Correct 189 ms 28544 KB Output is correct
70 Correct 72 ms 19880 KB Output is correct
71 Correct 188 ms 27812 KB Output is correct
72 Correct 146 ms 25292 KB Output is correct
73 Correct 219 ms 36072 KB Output is correct
74 Correct 69 ms 19904 KB Output is correct
75 Correct 59 ms 19144 KB Output is correct
76 Correct 145 ms 25352 KB Output is correct
77 Correct 228 ms 36200 KB Output is correct
78 Correct 97 ms 24048 KB Output is correct
79 Correct 70 ms 19216 KB Output is correct
80 Correct 30 ms 15676 KB Output is correct
81 Correct 112 ms 23824 KB Output is correct
82 Correct 148 ms 26740 KB Output is correct
83 Correct 30 ms 15592 KB Output is correct
84 Correct 137 ms 26648 KB Output is correct