Submission #655804

# Submission time Handle Problem Language Result Execution time Memory
655804 2022-11-05T15:12:25 Z KiriLL1ca Political Development (BOI17_politicaldevelopment) C++17
39 / 100
915 ms 26456 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fr first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pw(x) (1ll << x)
#define sz(x) (int)((x).size())
#define pb push_back
#define endl '\n'
#define mp make_pair
#define vec vector

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef unsigned long long ull;
typedef unsigned int uint;

template <typename T> inline bool umin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool umax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T>
using oset = tree<T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

inline void solve () {
        int n, k; cin >> n >> k;
        vector <int> cnt (n);
        vector <set <int>> g (n);
        for (int i = 0; i < n; ++i) {
                cin >> cnt[i];
                for (int j = 0; j < cnt[i]; ++j) {
                        int x; cin >> x;
                        g[i].insert(x);
                }
        }
        int ans = 0;
        set <pii> s; for (int i = 0; i < n; ++i) s.insert({cnt[i], i});
        while (sz(s)) {
                auto [_, i] = *s.begin(); s.erase(s.begin());
                vector <int> ar; ar.pb(i);
                for (auto j : g[i]) ar.pb(j);

                for (int msk = 0; msk < pw(sz(ar)); ++msk) {
                        if (__builtin_popcount(msk) <= ans) continue;
                        vector <int> b;
                        for (int j = 0; j < sz(ar); ++j) if (msk >> j & 1) b.pb(ar[j]);
                        bool okich = 1;
                        for (int i = 0; i < sz(b) && okich; ++i) {
                                for (int j = i + 1; j < sz(b) && okich; ++j) {
                                        if (g[b[i]].find(ar[j]) == g[b[i]].end()) okich = 0;
                                }
                        }
                        if (okich) umax(ans, __builtin_popcount(msk));
                }

                for (auto j : g[i]) {
                        s.erase({cnt[j], j});
                        --cnt[j]; g[j].erase(i);
                        s.insert({cnt[j], j});
                }
        }
        cout << ans << endl;
}

signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        #ifdef LOCAL
                freopen("input.txt", "r", stdin);
                freopen("output.txt", "w", stdout);
        #endif
        int t = 1; // cin >> t;
        while (t--) solve();
        return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 5 ms 1236 KB Output is correct
4 Correct 4 ms 1236 KB Output is correct
5 Correct 4 ms 1236 KB Output is correct
6 Correct 5 ms 1236 KB Output is correct
7 Correct 5 ms 1236 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 5 ms 1236 KB Output is correct
4 Correct 4 ms 1236 KB Output is correct
5 Correct 4 ms 1236 KB Output is correct
6 Correct 5 ms 1236 KB Output is correct
7 Correct 5 ms 1236 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 724 KB Output is correct
11 Correct 4 ms 1236 KB Output is correct
12 Correct 4 ms 1236 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 4 ms 1164 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 6 ms 1236 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 5 ms 1236 KB Output is correct
19 Correct 2 ms 724 KB Output is correct
20 Correct 3 ms 980 KB Output is correct
21 Correct 2 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 724 KB Output is correct
25 Correct 6 ms 1364 KB Output is correct
26 Correct 5 ms 1236 KB Output is correct
27 Correct 4 ms 1284 KB Output is correct
28 Correct 5 ms 1236 KB Output is correct
29 Correct 4 ms 1236 KB Output is correct
30 Correct 6 ms 1364 KB Output is correct
31 Correct 6 ms 1364 KB Output is correct
32 Correct 6 ms 1364 KB Output is correct
33 Correct 7 ms 1364 KB Output is correct
34 Correct 6 ms 1364 KB Output is correct
35 Correct 3 ms 852 KB Output is correct
36 Correct 3 ms 852 KB Output is correct
37 Correct 3 ms 852 KB Output is correct
38 Correct 2 ms 596 KB Output is correct
39 Correct 3 ms 664 KB Output is correct
40 Correct 9 ms 1748 KB Output is correct
41 Correct 3 ms 596 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 1 ms 724 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 599 ms 26456 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 621 ms 26396 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 610 ms 26340 KB Output is correct
16 Correct 601 ms 26356 KB Output is correct
17 Correct 598 ms 26404 KB Output is correct
18 Correct 598 ms 26340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 5 ms 1236 KB Output is correct
4 Correct 4 ms 1236 KB Output is correct
5 Correct 4 ms 1236 KB Output is correct
6 Correct 5 ms 1236 KB Output is correct
7 Correct 5 ms 1236 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 724 KB Output is correct
11 Correct 4 ms 1236 KB Output is correct
12 Correct 4 ms 1236 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 4 ms 1164 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 6 ms 1236 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 5 ms 1236 KB Output is correct
19 Correct 2 ms 724 KB Output is correct
20 Correct 3 ms 980 KB Output is correct
21 Correct 2 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 724 KB Output is correct
25 Correct 6 ms 1364 KB Output is correct
26 Correct 5 ms 1236 KB Output is correct
27 Correct 4 ms 1284 KB Output is correct
28 Correct 5 ms 1236 KB Output is correct
29 Correct 4 ms 1236 KB Output is correct
30 Correct 6 ms 1364 KB Output is correct
31 Correct 6 ms 1364 KB Output is correct
32 Correct 6 ms 1364 KB Output is correct
33 Correct 7 ms 1364 KB Output is correct
34 Correct 6 ms 1364 KB Output is correct
35 Correct 3 ms 852 KB Output is correct
36 Correct 3 ms 852 KB Output is correct
37 Correct 3 ms 852 KB Output is correct
38 Correct 2 ms 596 KB Output is correct
39 Correct 3 ms 664 KB Output is correct
40 Correct 9 ms 1748 KB Output is correct
41 Correct 3 ms 596 KB Output is correct
42 Correct 9 ms 1748 KB Output is correct
43 Correct 9 ms 1748 KB Output is correct
44 Correct 14 ms 2644 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 9 ms 1748 KB Output is correct
47 Correct 24 ms 2644 KB Output is correct
48 Correct 9 ms 1748 KB Output is correct
49 Correct 22 ms 2644 KB Output is correct
50 Correct 25 ms 2644 KB Output is correct
51 Correct 384 ms 4564 KB Output is correct
52 Correct 4 ms 1236 KB Output is correct
53 Correct 895 ms 4972 KB Output is correct
54 Correct 809 ms 4948 KB Output is correct
55 Correct 5 ms 1236 KB Output is correct
56 Correct 4 ms 1236 KB Output is correct
57 Correct 2 ms 724 KB Output is correct
58 Correct 915 ms 4968 KB Output is correct
59 Correct 9 ms 1748 KB Output is correct
60 Correct 5 ms 1236 KB Output is correct
61 Correct 7 ms 1668 KB Output is correct
62 Correct 7 ms 1748 KB Output is correct
63 Correct 15 ms 2624 KB Output is correct
64 Correct 13 ms 2388 KB Output is correct
65 Correct 8 ms 1620 KB Output is correct
66 Correct 7 ms 1748 KB Output is correct
67 Correct 49 ms 3028 KB Output is correct
68 Correct 12 ms 2388 KB Output is correct
69 Correct 9 ms 1620 KB Output is correct
70 Correct 15 ms 2388 KB Output is correct
71 Correct 44 ms 3028 KB Output is correct
72 Correct 38 ms 2884 KB Output is correct
73 Correct 4 ms 1236 KB Output is correct
74 Correct 15 ms 2528 KB Output is correct
75 Correct 37 ms 2900 KB Output is correct
76 Correct 13 ms 2004 KB Output is correct
77 Correct 166 ms 3412 KB Output is correct
78 Correct 4 ms 1236 KB Output is correct
79 Correct 81 ms 1884 KB Output is correct
80 Correct 12 ms 2004 KB Output is correct
81 Correct 166 ms 3412 KB Output is correct
82 Correct 2 ms 596 KB Output is correct
83 Correct 84 ms 1876 KB Output is correct
84 Correct 53 ms 2900 KB Output is correct
85 Correct 3 ms 596 KB Output is correct
86 Incorrect 38 ms 2876 KB Output isn't correct
87 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 5 ms 1236 KB Output is correct
4 Correct 4 ms 1236 KB Output is correct
5 Correct 4 ms 1236 KB Output is correct
6 Correct 5 ms 1236 KB Output is correct
7 Correct 5 ms 1236 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 724 KB Output is correct
11 Correct 4 ms 1236 KB Output is correct
12 Correct 4 ms 1236 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 4 ms 1164 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 6 ms 1236 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 5 ms 1236 KB Output is correct
19 Correct 2 ms 724 KB Output is correct
20 Correct 3 ms 980 KB Output is correct
21 Correct 2 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 724 KB Output is correct
25 Correct 6 ms 1364 KB Output is correct
26 Correct 5 ms 1236 KB Output is correct
27 Correct 4 ms 1284 KB Output is correct
28 Correct 5 ms 1236 KB Output is correct
29 Correct 4 ms 1236 KB Output is correct
30 Correct 6 ms 1364 KB Output is correct
31 Correct 6 ms 1364 KB Output is correct
32 Correct 6 ms 1364 KB Output is correct
33 Correct 7 ms 1364 KB Output is correct
34 Correct 6 ms 1364 KB Output is correct
35 Correct 3 ms 852 KB Output is correct
36 Correct 3 ms 852 KB Output is correct
37 Correct 3 ms 852 KB Output is correct
38 Correct 2 ms 596 KB Output is correct
39 Correct 3 ms 664 KB Output is correct
40 Correct 9 ms 1748 KB Output is correct
41 Correct 3 ms 596 KB Output is correct
42 Correct 9 ms 1748 KB Output is correct
43 Correct 9 ms 1748 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 181 ms 19252 KB Output is correct
46 Correct 76 ms 12252 KB Output is correct
47 Correct 201 ms 19312 KB Output is correct
48 Correct 214 ms 19276 KB Output is correct
49 Correct 52 ms 9888 KB Output is correct
50 Correct 297 ms 24036 KB Output is correct
51 Correct 196 ms 19192 KB Output is correct
52 Correct 49 ms 9864 KB Output is correct
53 Correct 55 ms 9908 KB Output is correct
54 Correct 16 ms 5144 KB Output is correct
55 Correct 312 ms 23964 KB Output is correct
56 Correct 31 ms 7508 KB Output is correct
57 Correct 52 ms 9820 KB Output is correct
58 Correct 63 ms 12156 KB Output is correct
59 Correct 30 ms 7568 KB Output is correct
60 Correct 32 ms 7568 KB Output is correct
61 Correct 68 ms 12268 KB Output is correct
62 Correct 53 ms 9960 KB Output is correct
63 Correct 105 ms 13388 KB Output is correct
64 Correct 30 ms 7508 KB Output is correct
65 Correct 138 ms 15716 KB Output is correct
66 Correct 47 ms 9912 KB Output is correct
67 Correct 102 ms 13316 KB Output is correct
68 Correct 125 ms 15108 KB Output is correct
69 Correct 134 ms 15704 KB Output is correct
70 Correct 53 ms 9812 KB Output is correct
71 Correct 126 ms 15208 KB Output is correct
72 Correct 102 ms 13044 KB Output is correct
73 Correct 170 ms 17244 KB Output is correct
74 Correct 56 ms 9812 KB Output is correct
75 Correct 56 ms 7304 KB Output is correct
76 Correct 96 ms 13028 KB Output is correct
77 Correct 177 ms 17356 KB Output is correct
78 Correct 83 ms 8784 KB Output is correct
79 Correct 58 ms 7252 KB Output is correct
80 Correct 23 ms 3780 KB Output is correct
81 Correct 81 ms 8696 KB Output is correct
82 Correct 117 ms 14604 KB Output is correct
83 Correct 23 ms 3796 KB Output is correct
84 Incorrect 125 ms 14696 KB Output isn't correct
85 Halted 0 ms 0 KB -