답안 #260447

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
260447 2020-08-10T09:23:43 Z dolphingarlic Political Development (BOI17_politicaldevelopment) C++14
100 / 100
1855 ms 27000 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

set<int> graph[50000];
bool tried[50000];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    queue<int> q;
    for (int i = 0; i < n; i++) {
        int s;
        cin >> s;
        if (s < k) {
            tried[i] = true;
            q.push(i);
        }
        while (s--) {
            int b;
            cin >> b;
            graph[i].insert(b);
        }
    }

    int ans = 0;
    while (q.size()) {
        int curr = q.front();
        q.pop();

        for (int i = 0; i < (1 << graph[curr].size()); i++) {
            if (__builtin_popcount(i) <= ans) continue;
            vector<int> adj;
            int tmp = i;
            for (int j : graph[curr]) {
                if (tmp & 1) adj.push_back(j);
                tmp >>= 1;
            }
            bool good = true;
            for (int j = 0; j < adj.size(); j++) {
                for (int l = j + 1; l < adj.size(); l++) {
                    good &= graph[adj[j]].find(adj[l]) != graph[adj[j]].end();
                }
            }
            if (good) ans = __builtin_popcount(i);
        }

        for (int i : graph[curr]) {
            graph[i].erase(curr);
            if (!tried[i] && graph[i].size() < k) {
                tried[i] = true;
                q.push(i);
            }
        }
        graph[curr].clear();
    }

    cout << ans + 1;
    return 0;
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:42:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int j = 0; j < adj.size(); j++) {
                             ~~^~~~~~~~~~~~
politicaldevelopment.cpp:43:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for (int l = j + 1; l < adj.size(); l++) {
                                     ~~^~~~~~~~~~~~
politicaldevelopment.cpp:52:46: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (!tried[i] && graph[i].size() < k) {
                              ~~~~~~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 6 ms 3200 KB Output is correct
4 Correct 6 ms 3200 KB Output is correct
5 Correct 5 ms 3200 KB Output is correct
6 Correct 5 ms 3200 KB Output is correct
7 Correct 6 ms 3200 KB Output is correct
8 Correct 2 ms 2720 KB Output is correct
9 Correct 2 ms 2688 KB Output is correct
10 Correct 2 ms 2688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 6 ms 3200 KB Output is correct
4 Correct 6 ms 3200 KB Output is correct
5 Correct 5 ms 3200 KB Output is correct
6 Correct 5 ms 3200 KB Output is correct
7 Correct 6 ms 3200 KB Output is correct
8 Correct 2 ms 2720 KB Output is correct
9 Correct 2 ms 2688 KB Output is correct
10 Correct 2 ms 2688 KB Output is correct
11 Correct 5 ms 3304 KB Output is correct
12 Correct 5 ms 3200 KB Output is correct
13 Correct 2 ms 2688 KB Output is correct
14 Correct 5 ms 3200 KB Output is correct
15 Correct 2 ms 2688 KB Output is correct
16 Correct 5 ms 3200 KB Output is correct
17 Correct 2 ms 2688 KB Output is correct
18 Correct 5 ms 3200 KB Output is correct
19 Correct 2 ms 2688 KB Output is correct
20 Correct 4 ms 2944 KB Output is correct
21 Correct 3 ms 2944 KB Output is correct
22 Correct 3 ms 2688 KB Output is correct
23 Correct 7 ms 3328 KB Output is correct
24 Correct 2 ms 2688 KB Output is correct
25 Correct 7 ms 3328 KB Output is correct
26 Correct 6 ms 3328 KB Output is correct
27 Correct 5 ms 3200 KB Output is correct
28 Correct 6 ms 3328 KB Output is correct
29 Correct 5 ms 3200 KB Output is correct
30 Correct 6 ms 3456 KB Output is correct
31 Correct 6 ms 3456 KB Output is correct
32 Correct 6 ms 3456 KB Output is correct
33 Correct 6 ms 3328 KB Output is correct
34 Correct 6 ms 3328 KB Output is correct
35 Correct 4 ms 3072 KB Output is correct
36 Correct 4 ms 3072 KB Output is correct
37 Correct 5 ms 3072 KB Output is correct
38 Correct 4 ms 2944 KB Output is correct
39 Correct 3 ms 2944 KB Output is correct
40 Correct 9 ms 3712 KB Output is correct
41 Correct 4 ms 2944 KB Output is correct
42 Correct 8 ms 3712 KB Output is correct
43 Correct 8 ms 3712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
4 Correct 2 ms 2688 KB Output is correct
5 Correct 2 ms 2688 KB Output is correct
6 Correct 2 ms 2688 KB Output is correct
7 Correct 2 ms 2688 KB Output is correct
8 Correct 2 ms 2688 KB Output is correct
9 Correct 2 ms 2688 KB Output is correct
10 Correct 2 ms 2688 KB Output is correct
11 Correct 1826 ms 27000 KB Output is correct
12 Correct 2 ms 2688 KB Output is correct
13 Correct 390 ms 26744 KB Output is correct
14 Correct 2 ms 2688 KB Output is correct
15 Correct 1855 ms 26800 KB Output is correct
16 Correct 456 ms 26784 KB Output is correct
17 Correct 1232 ms 26748 KB Output is correct
18 Correct 1359 ms 26872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 6 ms 3200 KB Output is correct
4 Correct 6 ms 3200 KB Output is correct
5 Correct 5 ms 3200 KB Output is correct
6 Correct 5 ms 3200 KB Output is correct
7 Correct 6 ms 3200 KB Output is correct
8 Correct 2 ms 2720 KB Output is correct
9 Correct 2 ms 2688 KB Output is correct
10 Correct 2 ms 2688 KB Output is correct
11 Correct 5 ms 3304 KB Output is correct
12 Correct 5 ms 3200 KB Output is correct
13 Correct 2 ms 2688 KB Output is correct
14 Correct 5 ms 3200 KB Output is correct
15 Correct 2 ms 2688 KB Output is correct
16 Correct 5 ms 3200 KB Output is correct
17 Correct 2 ms 2688 KB Output is correct
18 Correct 5 ms 3200 KB Output is correct
19 Correct 2 ms 2688 KB Output is correct
20 Correct 4 ms 2944 KB Output is correct
21 Correct 3 ms 2944 KB Output is correct
22 Correct 3 ms 2688 KB Output is correct
23 Correct 7 ms 3328 KB Output is correct
24 Correct 2 ms 2688 KB Output is correct
25 Correct 7 ms 3328 KB Output is correct
26 Correct 6 ms 3328 KB Output is correct
27 Correct 5 ms 3200 KB Output is correct
28 Correct 6 ms 3328 KB Output is correct
29 Correct 5 ms 3200 KB Output is correct
30 Correct 6 ms 3456 KB Output is correct
31 Correct 6 ms 3456 KB Output is correct
32 Correct 6 ms 3456 KB Output is correct
33 Correct 6 ms 3328 KB Output is correct
34 Correct 6 ms 3328 KB Output is correct
35 Correct 4 ms 3072 KB Output is correct
36 Correct 4 ms 3072 KB Output is correct
37 Correct 5 ms 3072 KB Output is correct
38 Correct 4 ms 2944 KB Output is correct
39 Correct 3 ms 2944 KB Output is correct
40 Correct 9 ms 3712 KB Output is correct
41 Correct 4 ms 2944 KB Output is correct
42 Correct 8 ms 3712 KB Output is correct
43 Correct 8 ms 3712 KB Output is correct
44 Correct 15 ms 4736 KB Output is correct
45 Correct 2 ms 2688 KB Output is correct
46 Correct 8 ms 3744 KB Output is correct
47 Correct 26 ms 4736 KB Output is correct
48 Correct 8 ms 3712 KB Output is correct
49 Correct 25 ms 4736 KB Output is correct
50 Correct 41 ms 4864 KB Output is correct
51 Correct 480 ms 7032 KB Output is correct
52 Correct 5 ms 3200 KB Output is correct
53 Correct 1393 ms 7424 KB Output is correct
54 Correct 1085 ms 7416 KB Output is correct
55 Correct 5 ms 3200 KB Output is correct
56 Correct 6 ms 3200 KB Output is correct
57 Correct 2 ms 2688 KB Output is correct
58 Correct 1282 ms 7436 KB Output is correct
59 Correct 7 ms 3712 KB Output is correct
60 Correct 5 ms 3200 KB Output is correct
61 Correct 9 ms 3712 KB Output is correct
62 Correct 7 ms 3712 KB Output is correct
63 Correct 14 ms 4736 KB Output is correct
64 Correct 15 ms 4480 KB Output is correct
65 Correct 9 ms 3584 KB Output is correct
66 Correct 8 ms 3712 KB Output is correct
67 Correct 33 ms 5248 KB Output is correct
68 Correct 12 ms 4480 KB Output is correct
69 Correct 7 ms 3584 KB Output is correct
70 Correct 16 ms 4608 KB Output is correct
71 Correct 23 ms 5120 KB Output is correct
72 Correct 20 ms 5120 KB Output is correct
73 Correct 5 ms 3200 KB Output is correct
74 Correct 15 ms 4608 KB Output is correct
75 Correct 19 ms 5120 KB Output is correct
76 Correct 17 ms 4096 KB Output is correct
77 Correct 312 ms 5740 KB Output is correct
78 Correct 5 ms 3200 KB Output is correct
79 Correct 162 ms 4224 KB Output is correct
80 Correct 26 ms 4096 KB Output is correct
81 Correct 343 ms 5632 KB Output is correct
82 Correct 4 ms 2944 KB Output is correct
83 Correct 160 ms 4232 KB Output is correct
84 Correct 152 ms 4992 KB Output is correct
85 Correct 4 ms 2944 KB Output is correct
86 Correct 42 ms 4992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 6 ms 3200 KB Output is correct
4 Correct 6 ms 3200 KB Output is correct
5 Correct 5 ms 3200 KB Output is correct
6 Correct 5 ms 3200 KB Output is correct
7 Correct 6 ms 3200 KB Output is correct
8 Correct 2 ms 2720 KB Output is correct
9 Correct 2 ms 2688 KB Output is correct
10 Correct 2 ms 2688 KB Output is correct
11 Correct 5 ms 3304 KB Output is correct
12 Correct 5 ms 3200 KB Output is correct
13 Correct 2 ms 2688 KB Output is correct
14 Correct 5 ms 3200 KB Output is correct
15 Correct 2 ms 2688 KB Output is correct
16 Correct 5 ms 3200 KB Output is correct
17 Correct 2 ms 2688 KB Output is correct
18 Correct 5 ms 3200 KB Output is correct
19 Correct 2 ms 2688 KB Output is correct
20 Correct 4 ms 2944 KB Output is correct
21 Correct 3 ms 2944 KB Output is correct
22 Correct 3 ms 2688 KB Output is correct
23 Correct 7 ms 3328 KB Output is correct
24 Correct 2 ms 2688 KB Output is correct
25 Correct 7 ms 3328 KB Output is correct
26 Correct 6 ms 3328 KB Output is correct
27 Correct 5 ms 3200 KB Output is correct
28 Correct 6 ms 3328 KB Output is correct
29 Correct 5 ms 3200 KB Output is correct
30 Correct 6 ms 3456 KB Output is correct
31 Correct 6 ms 3456 KB Output is correct
32 Correct 6 ms 3456 KB Output is correct
33 Correct 6 ms 3328 KB Output is correct
34 Correct 6 ms 3328 KB Output is correct
35 Correct 4 ms 3072 KB Output is correct
36 Correct 4 ms 3072 KB Output is correct
37 Correct 5 ms 3072 KB Output is correct
38 Correct 4 ms 2944 KB Output is correct
39 Correct 3 ms 2944 KB Output is correct
40 Correct 9 ms 3712 KB Output is correct
41 Correct 4 ms 2944 KB Output is correct
42 Correct 8 ms 3712 KB Output is correct
43 Correct 8 ms 3712 KB Output is correct
44 Correct 2 ms 2688 KB Output is correct
45 Correct 168 ms 18808 KB Output is correct
46 Correct 55 ms 10872 KB Output is correct
47 Correct 163 ms 18680 KB Output is correct
48 Correct 158 ms 18740 KB Output is correct
49 Correct 41 ms 8316 KB Output is correct
50 Correct 295 ms 24056 KB Output is correct
51 Correct 166 ms 18680 KB Output is correct
52 Correct 37 ms 8320 KB Output is correct
53 Correct 41 ms 8320 KB Output is correct
54 Correct 6 ms 3072 KB Output is correct
55 Correct 300 ms 24252 KB Output is correct
56 Correct 18 ms 5632 KB Output is correct
57 Correct 36 ms 8320 KB Output is correct
58 Correct 51 ms 10892 KB Output is correct
59 Correct 18 ms 5632 KB Output is correct
60 Correct 19 ms 5672 KB Output is correct
61 Correct 51 ms 10872 KB Output is correct
62 Correct 36 ms 8320 KB Output is correct
63 Correct 76 ms 12152 KB Output is correct
64 Correct 19 ms 5632 KB Output is correct
65 Correct 99 ms 14868 KB Output is correct
66 Correct 34 ms 8320 KB Output is correct
67 Correct 69 ms 12288 KB Output is correct
68 Correct 92 ms 14328 KB Output is correct
69 Correct 103 ms 14840 KB Output is correct
70 Correct 36 ms 8448 KB Output is correct
71 Correct 90 ms 14200 KB Output is correct
72 Correct 73 ms 11768 KB Output is correct
73 Correct 177 ms 16556 KB Output is correct
74 Correct 36 ms 8320 KB Output is correct
75 Correct 49 ms 7936 KB Output is correct
76 Correct 76 ms 11768 KB Output is correct
77 Correct 187 ms 16632 KB Output is correct
78 Correct 87 ms 9592 KB Output is correct
79 Correct 56 ms 7928 KB Output is correct
80 Correct 20 ms 5504 KB Output is correct
81 Correct 80 ms 9592 KB Output is correct
82 Correct 96 ms 13560 KB Output is correct
83 Correct 19 ms 5376 KB Output is correct
84 Correct 99 ms 13620 KB Output is correct