답안 #333215

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
333215 2020-12-04T23:30:12 Z limabeans Political Development (BOI17_politicaldevelopment) C++17
100 / 100
1240 ms 26860 KB
#include <bits/stdc++.h>
using namespace std;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 5e4 + 10;


int n,k;
set<int> g[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

    cin>>n>>k;

    for (int i=0; i<n; i++) {
	int t;
	cin>>t;
	while (t--) {
	    int x;
	    cin>>x;
	    g[i].insert(x);
	    g[x].insert(i);
	}
    }


    queue<int> qq;
    vector<bool> added(n, false);


    for (int i=0; i<n; i++) {
	if ((int)g[i].size()<k) {
	    qq.push(i);
	    added[i] = true;
	}
    }
    
    int ans = 0;

    while (qq.size()) {
	int at = qq.front();
	qq.pop();
	int len = g[at].size();
	for (int mask=0; mask<(1<<len); mask++) {
	    int val = __builtin_popcount(mask);
	    if (val <= ans) {
		continue;
	    }
	    int tmp = mask;
	    vector<int> w;
	    for (int x: g[at]) {
		if (tmp&1) {
		    w.push_back(x);
		}
		tmp >>= 1;
	    }

	    int N = w.size();
	    bool ok = true;
	    for (int i=0; i<N && ok; i++) {
		for (int j=i+1; j<N && ok; j++) {
		    ok &= (g[w[i]].count(w[j]));
		}
	    }

	    if (ok) {
		ans = max(ans, val);
	    }
	}

	for (int to: g[at]) {
	    g[to].erase(at);
	    if ((int)g[to].size()<k && !added[to]) {
		qq.push(to);
	    }
	}
	g[at].clear();
    }


    cout<<ans+1<<endl;    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 5 ms 3200 KB Output is correct
4 Correct 6 ms 3200 KB Output is correct
5 Correct 6 ms 3180 KB Output is correct
6 Correct 5 ms 3180 KB Output is correct
7 Correct 6 ms 3180 KB Output is correct
8 Correct 2 ms 2668 KB Output is correct
9 Correct 2 ms 2668 KB Output is correct
10 Correct 2 ms 2668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 5 ms 3200 KB Output is correct
4 Correct 6 ms 3200 KB Output is correct
5 Correct 6 ms 3180 KB Output is correct
6 Correct 5 ms 3180 KB Output is correct
7 Correct 6 ms 3180 KB Output is correct
8 Correct 2 ms 2668 KB Output is correct
9 Correct 2 ms 2668 KB Output is correct
10 Correct 2 ms 2668 KB Output is correct
11 Correct 6 ms 3180 KB Output is correct
12 Correct 6 ms 3180 KB Output is correct
13 Correct 2 ms 2668 KB Output is correct
14 Correct 6 ms 3180 KB Output is correct
15 Correct 2 ms 2668 KB Output is correct
16 Correct 5 ms 3200 KB Output is correct
17 Correct 2 ms 2668 KB Output is correct
18 Correct 6 ms 3200 KB Output is correct
19 Correct 2 ms 2668 KB Output is correct
20 Correct 3 ms 2944 KB Output is correct
21 Correct 3 ms 2924 KB Output is correct
22 Correct 2 ms 2668 KB Output is correct
23 Correct 6 ms 3308 KB Output is correct
24 Correct 2 ms 2668 KB Output is correct
25 Correct 6 ms 3308 KB Output is correct
26 Correct 6 ms 3328 KB Output is correct
27 Correct 5 ms 3180 KB Output is correct
28 Correct 6 ms 3308 KB Output is correct
29 Correct 5 ms 3180 KB Output is correct
30 Correct 7 ms 3436 KB Output is correct
31 Correct 6 ms 3436 KB Output is correct
32 Correct 7 ms 3436 KB Output is correct
33 Correct 6 ms 3436 KB Output is correct
34 Correct 8 ms 3436 KB Output is correct
35 Correct 4 ms 3052 KB Output is correct
36 Correct 4 ms 3052 KB Output is correct
37 Correct 4 ms 3052 KB Output is correct
38 Correct 3 ms 2924 KB Output is correct
39 Correct 4 ms 2924 KB Output is correct
40 Correct 9 ms 3692 KB Output is correct
41 Correct 3 ms 2924 KB Output is correct
42 Correct 8 ms 3692 KB Output is correct
43 Correct 8 ms 3692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2668 KB Output is correct
4 Correct 2 ms 2816 KB Output is correct
5 Correct 2 ms 2668 KB Output is correct
6 Correct 2 ms 2668 KB Output is correct
7 Correct 2 ms 2668 KB Output is correct
8 Correct 2 ms 2668 KB Output is correct
9 Correct 2 ms 2668 KB Output is correct
10 Correct 2 ms 2668 KB Output is correct
11 Correct 1199 ms 26860 KB Output is correct
12 Correct 2 ms 2688 KB Output is correct
13 Correct 440 ms 26732 KB Output is correct
14 Correct 2 ms 2668 KB Output is correct
15 Correct 1240 ms 26732 KB Output is correct
16 Correct 473 ms 26732 KB Output is correct
17 Correct 810 ms 26732 KB Output is correct
18 Correct 957 ms 26824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 5 ms 3200 KB Output is correct
4 Correct 6 ms 3200 KB Output is correct
5 Correct 6 ms 3180 KB Output is correct
6 Correct 5 ms 3180 KB Output is correct
7 Correct 6 ms 3180 KB Output is correct
8 Correct 2 ms 2668 KB Output is correct
9 Correct 2 ms 2668 KB Output is correct
10 Correct 2 ms 2668 KB Output is correct
11 Correct 6 ms 3180 KB Output is correct
12 Correct 6 ms 3180 KB Output is correct
13 Correct 2 ms 2668 KB Output is correct
14 Correct 6 ms 3180 KB Output is correct
15 Correct 2 ms 2668 KB Output is correct
16 Correct 5 ms 3200 KB Output is correct
17 Correct 2 ms 2668 KB Output is correct
18 Correct 6 ms 3200 KB Output is correct
19 Correct 2 ms 2668 KB Output is correct
20 Correct 3 ms 2944 KB Output is correct
21 Correct 3 ms 2924 KB Output is correct
22 Correct 2 ms 2668 KB Output is correct
23 Correct 6 ms 3308 KB Output is correct
24 Correct 2 ms 2668 KB Output is correct
25 Correct 6 ms 3308 KB Output is correct
26 Correct 6 ms 3328 KB Output is correct
27 Correct 5 ms 3180 KB Output is correct
28 Correct 6 ms 3308 KB Output is correct
29 Correct 5 ms 3180 KB Output is correct
30 Correct 7 ms 3436 KB Output is correct
31 Correct 6 ms 3436 KB Output is correct
32 Correct 7 ms 3436 KB Output is correct
33 Correct 6 ms 3436 KB Output is correct
34 Correct 8 ms 3436 KB Output is correct
35 Correct 4 ms 3052 KB Output is correct
36 Correct 4 ms 3052 KB Output is correct
37 Correct 4 ms 3052 KB Output is correct
38 Correct 3 ms 2924 KB Output is correct
39 Correct 4 ms 2924 KB Output is correct
40 Correct 9 ms 3692 KB Output is correct
41 Correct 3 ms 2924 KB Output is correct
42 Correct 8 ms 3692 KB Output is correct
43 Correct 8 ms 3692 KB Output is correct
44 Correct 14 ms 4844 KB Output is correct
45 Correct 2 ms 2668 KB Output is correct
46 Correct 9 ms 3692 KB Output is correct
47 Correct 23 ms 4716 KB Output is correct
48 Correct 9 ms 3692 KB Output is correct
49 Correct 23 ms 4716 KB Output is correct
50 Correct 32 ms 4716 KB Output is correct
51 Correct 268 ms 6892 KB Output is correct
52 Correct 6 ms 3180 KB Output is correct
53 Correct 599 ms 7404 KB Output is correct
54 Correct 555 ms 7532 KB Output is correct
55 Correct 6 ms 3180 KB Output is correct
56 Correct 5 ms 3180 KB Output is correct
57 Correct 2 ms 2668 KB Output is correct
58 Correct 615 ms 7532 KB Output is correct
59 Correct 8 ms 3692 KB Output is correct
60 Correct 5 ms 3180 KB Output is correct
61 Correct 7 ms 3692 KB Output is correct
62 Correct 7 ms 3692 KB Output is correct
63 Correct 15 ms 4844 KB Output is correct
64 Correct 12 ms 4460 KB Output is correct
65 Correct 8 ms 3564 KB Output is correct
66 Correct 7 ms 3692 KB Output is correct
67 Correct 30 ms 5228 KB Output is correct
68 Correct 12 ms 4460 KB Output is correct
69 Correct 8 ms 3564 KB Output is correct
70 Correct 16 ms 4588 KB Output is correct
71 Correct 24 ms 5228 KB Output is correct
72 Correct 22 ms 5120 KB Output is correct
73 Correct 5 ms 3180 KB Output is correct
74 Correct 16 ms 4588 KB Output is correct
75 Correct 21 ms 5100 KB Output is correct
76 Correct 15 ms 4076 KB Output is correct
77 Correct 184 ms 5868 KB Output is correct
78 Correct 5 ms 3180 KB Output is correct
79 Correct 93 ms 4204 KB Output is correct
80 Correct 16 ms 4076 KB Output is correct
81 Correct 182 ms 5740 KB Output is correct
82 Correct 4 ms 2924 KB Output is correct
83 Correct 93 ms 4204 KB Output is correct
84 Correct 90 ms 5100 KB Output is correct
85 Correct 4 ms 2924 KB Output is correct
86 Correct 28 ms 5100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 5 ms 3200 KB Output is correct
4 Correct 6 ms 3200 KB Output is correct
5 Correct 6 ms 3180 KB Output is correct
6 Correct 5 ms 3180 KB Output is correct
7 Correct 6 ms 3180 KB Output is correct
8 Correct 2 ms 2668 KB Output is correct
9 Correct 2 ms 2668 KB Output is correct
10 Correct 2 ms 2668 KB Output is correct
11 Correct 6 ms 3180 KB Output is correct
12 Correct 6 ms 3180 KB Output is correct
13 Correct 2 ms 2668 KB Output is correct
14 Correct 6 ms 3180 KB Output is correct
15 Correct 2 ms 2668 KB Output is correct
16 Correct 5 ms 3200 KB Output is correct
17 Correct 2 ms 2668 KB Output is correct
18 Correct 6 ms 3200 KB Output is correct
19 Correct 2 ms 2668 KB Output is correct
20 Correct 3 ms 2944 KB Output is correct
21 Correct 3 ms 2924 KB Output is correct
22 Correct 2 ms 2668 KB Output is correct
23 Correct 6 ms 3308 KB Output is correct
24 Correct 2 ms 2668 KB Output is correct
25 Correct 6 ms 3308 KB Output is correct
26 Correct 6 ms 3328 KB Output is correct
27 Correct 5 ms 3180 KB Output is correct
28 Correct 6 ms 3308 KB Output is correct
29 Correct 5 ms 3180 KB Output is correct
30 Correct 7 ms 3436 KB Output is correct
31 Correct 6 ms 3436 KB Output is correct
32 Correct 7 ms 3436 KB Output is correct
33 Correct 6 ms 3436 KB Output is correct
34 Correct 8 ms 3436 KB Output is correct
35 Correct 4 ms 3052 KB Output is correct
36 Correct 4 ms 3052 KB Output is correct
37 Correct 4 ms 3052 KB Output is correct
38 Correct 3 ms 2924 KB Output is correct
39 Correct 4 ms 2924 KB Output is correct
40 Correct 9 ms 3692 KB Output is correct
41 Correct 3 ms 2924 KB Output is correct
42 Correct 8 ms 3692 KB Output is correct
43 Correct 8 ms 3692 KB Output is correct
44 Correct 2 ms 2668 KB Output is correct
45 Correct 238 ms 18712 KB Output is correct
46 Correct 87 ms 10860 KB Output is correct
47 Correct 261 ms 18924 KB Output is correct
48 Correct 248 ms 18816 KB Output is correct
49 Correct 55 ms 8300 KB Output is correct
50 Correct 345 ms 24044 KB Output is correct
51 Correct 256 ms 18796 KB Output is correct
52 Correct 48 ms 8300 KB Output is correct
53 Correct 56 ms 8428 KB Output is correct
54 Correct 6 ms 3052 KB Output is correct
55 Correct 351 ms 24192 KB Output is correct
56 Correct 19 ms 5612 KB Output is correct
57 Correct 50 ms 8300 KB Output is correct
58 Correct 57 ms 10860 KB Output is correct
59 Correct 18 ms 5612 KB Output is correct
60 Correct 18 ms 5612 KB Output is correct
61 Correct 57 ms 10860 KB Output is correct
62 Correct 38 ms 8300 KB Output is correct
63 Correct 99 ms 12140 KB Output is correct
64 Correct 19 ms 5612 KB Output is correct
65 Correct 141 ms 14828 KB Output is correct
66 Correct 37 ms 8300 KB Output is correct
67 Correct 102 ms 12140 KB Output is correct
68 Correct 140 ms 14060 KB Output is correct
69 Correct 149 ms 14700 KB Output is correct
70 Correct 42 ms 8320 KB Output is correct
71 Correct 141 ms 14188 KB Output is correct
72 Correct 95 ms 11756 KB Output is correct
73 Correct 210 ms 16492 KB Output is correct
74 Correct 42 ms 8300 KB Output is correct
75 Correct 50 ms 7916 KB Output is correct
76 Correct 104 ms 11884 KB Output is correct
77 Correct 210 ms 16492 KB Output is correct
78 Correct 84 ms 9580 KB Output is correct
79 Correct 50 ms 7916 KB Output is correct
80 Correct 23 ms 5356 KB Output is correct
81 Correct 88 ms 9580 KB Output is correct
82 Correct 112 ms 13548 KB Output is correct
83 Correct 22 ms 5356 KB Output is correct
84 Correct 119 ms 13548 KB Output is correct