답안 #478055

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
478055 2021-10-05T12:36:52 Z Sohsoh84 Political Development (BOI17_politicaldevelopment) C++17
16 / 100
326 ms 69272 KB
// ?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

#define all(x)			(x).begin(),(x).end()
#define X			first
#define Y			second
#define sep			' '
#define endl			'\n'
#define debug(x)		cerr << #x << ": " <<  x << endl;

const ll MAXN = 1e6 + 10;

set<int> adj[MAXN];
set<pll> st;
int n, k, ans = 1, msk_adj[MAXN];
bool dp[MAXN];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		int d;
		cin >> d;
		for (int j = 1; j <= d; j++) {
			int v;
			cin >> v;
			v++;
			adj[i].insert(v);
		}
		
		st.insert({adj[i].size(), i});
	}

	while (!st.empty()) {
		int v = st.begin() -> Y;
		st.erase(st.begin());

		vector<int> vec;
		for (int e : adj[v]) {
			st.erase({adj[e].size(), e});
			adj[e].erase(v);
			vec.push_back(e);
			st.insert({adj[e].size(), e});
		}

		int sz = vec.size();
		for (int i = 0; i < sz; i++)
			for (int j = 0; j < sz; j++)
				msk_adj[i] ^= (adj[vec[i]].find(vec[j]) == adj[vec[i]].end() ? 0 : (1 << j));

		dp[0] = true;
		for (int msk = 1; msk < (1 << sz); msk++) {
			int ind = __builtin_ctz(msk), tmsk = msk - (1 << ind);
			dp[msk] = (dp[tmsk] && (tmsk & msk_adj[ind]) == tmsk);
		
			if (dp[msk]) ans = max(ans, __builtin_popcount(msk) + 1);
		}

	}

	cout << ans << endl;
	return 0; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 47272 KB Output is correct
2 Correct 23 ms 47180 KB Output is correct
3 Correct 30 ms 48136 KB Output is correct
4 Correct 28 ms 48000 KB Output is correct
5 Correct 30 ms 48040 KB Output is correct
6 Correct 29 ms 48024 KB Output is correct
7 Correct 30 ms 48024 KB Output is correct
8 Correct 27 ms 47564 KB Output is correct
9 Correct 24 ms 47180 KB Output is correct
10 Correct 25 ms 47524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 47272 KB Output is correct
2 Correct 23 ms 47180 KB Output is correct
3 Correct 30 ms 48136 KB Output is correct
4 Correct 28 ms 48000 KB Output is correct
5 Correct 30 ms 48040 KB Output is correct
6 Correct 29 ms 48024 KB Output is correct
7 Correct 30 ms 48024 KB Output is correct
8 Correct 27 ms 47564 KB Output is correct
9 Correct 24 ms 47180 KB Output is correct
10 Correct 25 ms 47524 KB Output is correct
11 Correct 28 ms 48040 KB Output is correct
12 Correct 28 ms 48080 KB Output is correct
13 Correct 26 ms 47288 KB Output is correct
14 Correct 29 ms 48016 KB Output is correct
15 Correct 24 ms 47180 KB Output is correct
16 Correct 30 ms 47992 KB Output is correct
17 Correct 23 ms 47244 KB Output is correct
18 Correct 32 ms 48064 KB Output is correct
19 Correct 27 ms 47564 KB Output is correct
20 Correct 28 ms 47716 KB Output is correct
21 Correct 27 ms 47820 KB Output is correct
22 Correct 26 ms 47564 KB Output is correct
23 Correct 33 ms 48152 KB Output is correct
24 Correct 28 ms 47576 KB Output is correct
25 Correct 30 ms 48076 KB Output is correct
26 Correct 30 ms 48080 KB Output is correct
27 Correct 28 ms 48040 KB Output is correct
28 Correct 33 ms 48076 KB Output is correct
29 Correct 30 ms 47980 KB Output is correct
30 Correct 35 ms 48204 KB Output is correct
31 Correct 35 ms 48236 KB Output is correct
32 Correct 30 ms 48204 KB Output is correct
33 Correct 32 ms 48212 KB Output is correct
34 Correct 32 ms 48224 KB Output is correct
35 Correct 28 ms 47768 KB Output is correct
36 Correct 28 ms 47768 KB Output is correct
37 Correct 31 ms 47748 KB Output is correct
38 Correct 28 ms 47564 KB Output is correct
39 Correct 28 ms 47564 KB Output is correct
40 Correct 35 ms 48460 KB Output is correct
41 Correct 26 ms 47592 KB Output is correct
42 Correct 39 ms 48536 KB Output is correct
43 Correct 38 ms 48528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 47548 KB Output is correct
2 Correct 24 ms 47192 KB Output is correct
3 Correct 25 ms 47260 KB Output is correct
4 Correct 28 ms 47172 KB Output is correct
5 Correct 25 ms 47220 KB Output is correct
6 Incorrect 24 ms 47180 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 47272 KB Output is correct
2 Correct 23 ms 47180 KB Output is correct
3 Correct 30 ms 48136 KB Output is correct
4 Correct 28 ms 48000 KB Output is correct
5 Correct 30 ms 48040 KB Output is correct
6 Correct 29 ms 48024 KB Output is correct
7 Correct 30 ms 48024 KB Output is correct
8 Correct 27 ms 47564 KB Output is correct
9 Correct 24 ms 47180 KB Output is correct
10 Correct 25 ms 47524 KB Output is correct
11 Correct 28 ms 48040 KB Output is correct
12 Correct 28 ms 48080 KB Output is correct
13 Correct 26 ms 47288 KB Output is correct
14 Correct 29 ms 48016 KB Output is correct
15 Correct 24 ms 47180 KB Output is correct
16 Correct 30 ms 47992 KB Output is correct
17 Correct 23 ms 47244 KB Output is correct
18 Correct 32 ms 48064 KB Output is correct
19 Correct 27 ms 47564 KB Output is correct
20 Correct 28 ms 47716 KB Output is correct
21 Correct 27 ms 47820 KB Output is correct
22 Correct 26 ms 47564 KB Output is correct
23 Correct 33 ms 48152 KB Output is correct
24 Correct 28 ms 47576 KB Output is correct
25 Correct 30 ms 48076 KB Output is correct
26 Correct 30 ms 48080 KB Output is correct
27 Correct 28 ms 48040 KB Output is correct
28 Correct 33 ms 48076 KB Output is correct
29 Correct 30 ms 47980 KB Output is correct
30 Correct 35 ms 48204 KB Output is correct
31 Correct 35 ms 48236 KB Output is correct
32 Correct 30 ms 48204 KB Output is correct
33 Correct 32 ms 48212 KB Output is correct
34 Correct 32 ms 48224 KB Output is correct
35 Correct 28 ms 47768 KB Output is correct
36 Correct 28 ms 47768 KB Output is correct
37 Correct 31 ms 47748 KB Output is correct
38 Correct 28 ms 47564 KB Output is correct
39 Correct 28 ms 47564 KB Output is correct
40 Correct 35 ms 48460 KB Output is correct
41 Correct 26 ms 47592 KB Output is correct
42 Correct 39 ms 48536 KB Output is correct
43 Correct 38 ms 48528 KB Output is correct
44 Incorrect 50 ms 49452 KB Output isn't correct
45 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 47272 KB Output is correct
2 Correct 23 ms 47180 KB Output is correct
3 Correct 30 ms 48136 KB Output is correct
4 Correct 28 ms 48000 KB Output is correct
5 Correct 30 ms 48040 KB Output is correct
6 Correct 29 ms 48024 KB Output is correct
7 Correct 30 ms 48024 KB Output is correct
8 Correct 27 ms 47564 KB Output is correct
9 Correct 24 ms 47180 KB Output is correct
10 Correct 25 ms 47524 KB Output is correct
11 Correct 28 ms 48040 KB Output is correct
12 Correct 28 ms 48080 KB Output is correct
13 Correct 26 ms 47288 KB Output is correct
14 Correct 29 ms 48016 KB Output is correct
15 Correct 24 ms 47180 KB Output is correct
16 Correct 30 ms 47992 KB Output is correct
17 Correct 23 ms 47244 KB Output is correct
18 Correct 32 ms 48064 KB Output is correct
19 Correct 27 ms 47564 KB Output is correct
20 Correct 28 ms 47716 KB Output is correct
21 Correct 27 ms 47820 KB Output is correct
22 Correct 26 ms 47564 KB Output is correct
23 Correct 33 ms 48152 KB Output is correct
24 Correct 28 ms 47576 KB Output is correct
25 Correct 30 ms 48076 KB Output is correct
26 Correct 30 ms 48080 KB Output is correct
27 Correct 28 ms 48040 KB Output is correct
28 Correct 33 ms 48076 KB Output is correct
29 Correct 30 ms 47980 KB Output is correct
30 Correct 35 ms 48204 KB Output is correct
31 Correct 35 ms 48236 KB Output is correct
32 Correct 30 ms 48204 KB Output is correct
33 Correct 32 ms 48212 KB Output is correct
34 Correct 32 ms 48224 KB Output is correct
35 Correct 28 ms 47768 KB Output is correct
36 Correct 28 ms 47768 KB Output is correct
37 Correct 31 ms 47748 KB Output is correct
38 Correct 28 ms 47564 KB Output is correct
39 Correct 28 ms 47564 KB Output is correct
40 Correct 35 ms 48460 KB Output is correct
41 Correct 26 ms 47592 KB Output is correct
42 Correct 39 ms 48536 KB Output is correct
43 Correct 38 ms 48528 KB Output is correct
44 Correct 30 ms 47296 KB Output is correct
45 Correct 290 ms 64480 KB Output is correct
46 Correct 125 ms 57376 KB Output is correct
47 Correct 326 ms 64512 KB Output is correct
48 Correct 292 ms 64492 KB Output is correct
49 Correct 86 ms 55108 KB Output is correct
50 Correct 308 ms 69272 KB Output is correct
51 Correct 292 ms 64408 KB Output is correct
52 Correct 91 ms 55108 KB Output is correct
53 Correct 83 ms 55108 KB Output is correct
54 Correct 44 ms 50460 KB Output is correct
55 Correct 324 ms 69188 KB Output is correct
56 Correct 57 ms 52756 KB Output is correct
57 Correct 95 ms 55108 KB Output is correct
58 Incorrect 115 ms 57448 KB Output isn't correct
59 Halted 0 ms 0 KB -