Submission #550259

# Submission time Handle Problem Language Result Execution time Memory
550259 2022-04-17T18:32:45 Z OttoTheDino Political Development (BOI17_politicaldevelopment) C++17
100 / 100
405 ms 28780 KB
#include <bits/stdc++.h>
using namespace std;

#define rep(i,s,e)                  for (int i = s; i <= e; ++i)
#define rrep(i,s,e)                 for (int i = s; i >= e; --i)
#define pb                          push_back
#define pf                          push_front
#define fi                          first
#define se                          second
#define all(a)                      a.begin(), a.end()
#define sz(a)                       (int)a.size()
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, K, ans = 1; cin >> n >> K;

    set<int> adj[n+1];
    set<ii> st;

    rep (i,1,n) {
        int d; cin >> d;
        rep (j,1,d) {
            int v; cin >> v;
            adj[i].insert(v+1);
        }
    }

    rep (i,1,n) st.insert({adj[i].size(), i});

    while (!st.empty()) {
        auto it = st.begin();
        int sz = (*it).fi+1, u = (*it).se;
        st.erase(it);

        vi bois;
        bois.pb(u);
        for (int v : adj[u]) bois.pb(v);

        while (true) {
            bool suc = 0;
            rep (i,0,(1<<sz)-1) {
                if (__builtin_popcount(i)==ans+1) {
                    bool suc2 = 1;
                    rep (j,0,sz-1) {
                        if (!(i&(1<<j))) continue;
                        rep (k,j+1,sz-1) {
                            if (!(i&(1<<k))) continue;
                            if (adj[bois[j]].find(bois[k])==adj[bois[j]].end()) {
                                suc2 = 0;
                                goto out;
                            }
                        }
                    } 
                    out:
                    if (suc2) {
                        suc = 1;
                        break;
                    }
                }
            }

            if (suc) ++ans;
            else break;
        }

        for (int v : adj[u]) {
            st.erase({adj[v].size(), v});
            adj[v].erase(u);
            st.insert({adj[v].size(), v});
        }
    }

    cout << ans << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 8 ms 1228 KB Output is correct
4 Correct 5 ms 1236 KB Output is correct
5 Correct 6 ms 1236 KB Output is correct
6 Correct 6 ms 1236 KB Output is correct
7 Correct 6 ms 1236 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 8 ms 1228 KB Output is correct
4 Correct 5 ms 1236 KB Output is correct
5 Correct 6 ms 1236 KB Output is correct
6 Correct 6 ms 1236 KB Output is correct
7 Correct 6 ms 1236 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 716 KB Output is correct
11 Correct 4 ms 1236 KB Output is correct
12 Correct 5 ms 1236 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 6 ms 1236 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 6 ms 1224 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 6 ms 1236 KB Output is correct
19 Correct 2 ms 724 KB Output is correct
20 Correct 3 ms 972 KB Output is correct
21 Correct 3 ms 980 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 6 ms 1364 KB Output is correct
24 Correct 2 ms 780 KB Output is correct
25 Correct 7 ms 1360 KB Output is correct
26 Correct 5 ms 1364 KB Output is correct
27 Correct 6 ms 1232 KB Output is correct
28 Correct 9 ms 1364 KB Output is correct
29 Correct 5 ms 1236 KB Output is correct
30 Correct 7 ms 1484 KB Output is correct
31 Correct 6 ms 1364 KB Output is correct
32 Correct 6 ms 1364 KB Output is correct
33 Correct 6 ms 1364 KB Output is correct
34 Correct 6 ms 1456 KB Output is correct
35 Correct 3 ms 852 KB Output is correct
36 Correct 3 ms 852 KB Output is correct
37 Correct 4 ms 852 KB Output is correct
38 Correct 3 ms 584 KB Output is correct
39 Correct 3 ms 596 KB Output is correct
40 Correct 10 ms 1748 KB Output is correct
41 Correct 4 ms 588 KB Output is correct
42 Correct 9 ms 1748 KB Output is correct
43 Correct 9 ms 1748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 724 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 362 ms 28776 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 385 ms 28772 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 352 ms 28772 KB Output is correct
16 Correct 405 ms 28780 KB Output is correct
17 Correct 382 ms 28772 KB Output is correct
18 Correct 358 ms 28764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 8 ms 1228 KB Output is correct
4 Correct 5 ms 1236 KB Output is correct
5 Correct 6 ms 1236 KB Output is correct
6 Correct 6 ms 1236 KB Output is correct
7 Correct 6 ms 1236 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 716 KB Output is correct
11 Correct 4 ms 1236 KB Output is correct
12 Correct 5 ms 1236 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 6 ms 1236 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 6 ms 1224 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 6 ms 1236 KB Output is correct
19 Correct 2 ms 724 KB Output is correct
20 Correct 3 ms 972 KB Output is correct
21 Correct 3 ms 980 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 6 ms 1364 KB Output is correct
24 Correct 2 ms 780 KB Output is correct
25 Correct 7 ms 1360 KB Output is correct
26 Correct 5 ms 1364 KB Output is correct
27 Correct 6 ms 1232 KB Output is correct
28 Correct 9 ms 1364 KB Output is correct
29 Correct 5 ms 1236 KB Output is correct
30 Correct 7 ms 1484 KB Output is correct
31 Correct 6 ms 1364 KB Output is correct
32 Correct 6 ms 1364 KB Output is correct
33 Correct 6 ms 1364 KB Output is correct
34 Correct 6 ms 1456 KB Output is correct
35 Correct 3 ms 852 KB Output is correct
36 Correct 3 ms 852 KB Output is correct
37 Correct 4 ms 852 KB Output is correct
38 Correct 3 ms 584 KB Output is correct
39 Correct 3 ms 596 KB Output is correct
40 Correct 10 ms 1748 KB Output is correct
41 Correct 4 ms 588 KB Output is correct
42 Correct 9 ms 1748 KB Output is correct
43 Correct 9 ms 1748 KB Output is correct
44 Correct 19 ms 2856 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 11 ms 1836 KB Output is correct
47 Correct 21 ms 2816 KB Output is correct
48 Correct 10 ms 1748 KB Output is correct
49 Correct 22 ms 2772 KB Output is correct
50 Correct 20 ms 2768 KB Output is correct
51 Correct 89 ms 4912 KB Output is correct
52 Correct 5 ms 1236 KB Output is correct
53 Correct 74 ms 5408 KB Output is correct
54 Correct 170 ms 5428 KB Output is correct
55 Correct 5 ms 1316 KB Output is correct
56 Correct 7 ms 1312 KB Output is correct
57 Correct 2 ms 724 KB Output is correct
58 Correct 70 ms 5332 KB Output is correct
59 Correct 7 ms 1740 KB Output is correct
60 Correct 5 ms 1236 KB Output is correct
61 Correct 8 ms 1748 KB Output is correct
62 Correct 11 ms 1748 KB Output is correct
63 Correct 18 ms 2784 KB Output is correct
64 Correct 14 ms 2532 KB Output is correct
65 Correct 10 ms 1660 KB Output is correct
66 Correct 11 ms 1836 KB Output is correct
67 Correct 32 ms 3276 KB Output is correct
68 Correct 13 ms 2516 KB Output is correct
69 Correct 8 ms 1620 KB Output is correct
70 Correct 16 ms 2640 KB Output is correct
71 Correct 27 ms 3156 KB Output is correct
72 Correct 29 ms 3156 KB Output is correct
73 Correct 6 ms 1228 KB Output is correct
74 Correct 16 ms 2660 KB Output is correct
75 Correct 31 ms 3156 KB Output is correct
76 Correct 18 ms 2172 KB Output is correct
77 Correct 41 ms 3736 KB Output is correct
78 Correct 4 ms 1188 KB Output is correct
79 Correct 19 ms 2004 KB Output is correct
80 Correct 11 ms 2164 KB Output is correct
81 Correct 39 ms 3680 KB Output is correct
82 Correct 3 ms 596 KB Output is correct
83 Correct 20 ms 2004 KB Output is correct
84 Correct 35 ms 3016 KB Output is correct
85 Correct 4 ms 608 KB Output is correct
86 Correct 22 ms 3056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 8 ms 1228 KB Output is correct
4 Correct 5 ms 1236 KB Output is correct
5 Correct 6 ms 1236 KB Output is correct
6 Correct 6 ms 1236 KB Output is correct
7 Correct 6 ms 1236 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 716 KB Output is correct
11 Correct 4 ms 1236 KB Output is correct
12 Correct 5 ms 1236 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 6 ms 1236 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 6 ms 1224 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 6 ms 1236 KB Output is correct
19 Correct 2 ms 724 KB Output is correct
20 Correct 3 ms 972 KB Output is correct
21 Correct 3 ms 980 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 6 ms 1364 KB Output is correct
24 Correct 2 ms 780 KB Output is correct
25 Correct 7 ms 1360 KB Output is correct
26 Correct 5 ms 1364 KB Output is correct
27 Correct 6 ms 1232 KB Output is correct
28 Correct 9 ms 1364 KB Output is correct
29 Correct 5 ms 1236 KB Output is correct
30 Correct 7 ms 1484 KB Output is correct
31 Correct 6 ms 1364 KB Output is correct
32 Correct 6 ms 1364 KB Output is correct
33 Correct 6 ms 1364 KB Output is correct
34 Correct 6 ms 1456 KB Output is correct
35 Correct 3 ms 852 KB Output is correct
36 Correct 3 ms 852 KB Output is correct
37 Correct 4 ms 852 KB Output is correct
38 Correct 3 ms 584 KB Output is correct
39 Correct 3 ms 596 KB Output is correct
40 Correct 10 ms 1748 KB Output is correct
41 Correct 4 ms 588 KB Output is correct
42 Correct 9 ms 1748 KB Output is correct
43 Correct 9 ms 1748 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 191 ms 20888 KB Output is correct
46 Correct 99 ms 12984 KB Output is correct
47 Correct 218 ms 20940 KB Output is correct
48 Correct 183 ms 20808 KB Output is correct
49 Correct 55 ms 10376 KB Output is correct
50 Correct 200 ms 26140 KB Output is correct
51 Correct 224 ms 20800 KB Output is correct
52 Correct 50 ms 10360 KB Output is correct
53 Correct 54 ms 10352 KB Output is correct
54 Correct 15 ms 5048 KB Output is correct
55 Correct 224 ms 26132 KB Output is correct
56 Correct 36 ms 7724 KB Output is correct
57 Correct 58 ms 10364 KB Output is correct
58 Correct 61 ms 12896 KB Output is correct
59 Correct 30 ms 7636 KB Output is correct
60 Correct 30 ms 7636 KB Output is correct
61 Correct 68 ms 12936 KB Output is correct
62 Correct 67 ms 10384 KB Output is correct
63 Correct 111 ms 14300 KB Output is correct
64 Correct 32 ms 7636 KB Output is correct
65 Correct 138 ms 16948 KB Output is correct
66 Correct 52 ms 10292 KB Output is correct
67 Correct 120 ms 14292 KB Output is correct
68 Correct 140 ms 16264 KB Output is correct
69 Correct 133 ms 16900 KB Output is correct
70 Correct 51 ms 10356 KB Output is correct
71 Correct 157 ms 16256 KB Output is correct
72 Correct 104 ms 13868 KB Output is correct
73 Correct 153 ms 18640 KB Output is correct
74 Correct 54 ms 10360 KB Output is correct
75 Correct 54 ms 7804 KB Output is correct
76 Correct 108 ms 13868 KB Output is correct
77 Correct 174 ms 18616 KB Output is correct
78 Correct 75 ms 9396 KB Output is correct
79 Correct 54 ms 7756 KB Output is correct
80 Correct 31 ms 4040 KB Output is correct
81 Correct 74 ms 9432 KB Output is correct
82 Correct 113 ms 15544 KB Output is correct
83 Correct 25 ms 4052 KB Output is correct
84 Correct 119 ms 15620 KB Output is correct