답안 #655807

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
655807 2022-11-05T15:13:57 Z KiriLL1ca Political Development (BOI17_politicaldevelopment) C++17
39 / 100
523 ms 26368 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;
                for (auto j : g[i]) ar.pb(j);

                for (int msk = 0; msk < pw(sz(ar)); ++msk) {
                        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 + 1 << 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;
}
# 결과 실행 시간 메모리 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 4 ms 1236 KB Output is correct
7 Correct 4 ms 1236 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 724 KB Output is correct
# 결과 실행 시간 메모리 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 4 ms 1236 KB Output is correct
7 Correct 4 ms 1236 KB Output is correct
8 Correct 2 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 0 ms 212 KB Output is correct
14 Correct 4 ms 1236 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 5 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 5 ms 1044 KB Output is correct
21 Correct 2 ms 980 KB Output is correct
22 Correct 2 ms 724 KB Output is correct
23 Correct 6 ms 1364 KB Output is correct
24 Correct 1 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 7 ms 1236 KB Output is correct
28 Correct 6 ms 1236 KB Output is correct
29 Correct 6 ms 1236 KB Output is correct
30 Correct 7 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 8 ms 1364 KB Output is correct
34 Correct 8 ms 1364 KB Output is correct
35 Correct 4 ms 880 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 2 ms 596 KB Output is correct
40 Correct 9 ms 1748 KB Output is correct
41 Correct 2 ms 596 KB Output is correct
42 Correct 9 ms 1704 KB Output is correct
43 Correct 9 ms 1748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 724 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 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 503 ms 26340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 482 ms 26304 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 503 ms 26336 KB Output is correct
16 Correct 504 ms 26340 KB Output is correct
17 Correct 523 ms 26368 KB Output is correct
18 Correct 494 ms 26228 KB Output is correct
# 결과 실행 시간 메모리 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 4 ms 1236 KB Output is correct
7 Correct 4 ms 1236 KB Output is correct
8 Correct 2 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 0 ms 212 KB Output is correct
14 Correct 4 ms 1236 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 5 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 5 ms 1044 KB Output is correct
21 Correct 2 ms 980 KB Output is correct
22 Correct 2 ms 724 KB Output is correct
23 Correct 6 ms 1364 KB Output is correct
24 Correct 1 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 7 ms 1236 KB Output is correct
28 Correct 6 ms 1236 KB Output is correct
29 Correct 6 ms 1236 KB Output is correct
30 Correct 7 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 8 ms 1364 KB Output is correct
34 Correct 8 ms 1364 KB Output is correct
35 Correct 4 ms 880 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 2 ms 596 KB Output is correct
40 Correct 9 ms 1748 KB Output is correct
41 Correct 2 ms 596 KB Output is correct
42 Correct 9 ms 1704 KB Output is correct
43 Correct 9 ms 1748 KB Output is correct
44 Correct 59 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 1620 KB Output is correct
49 Correct 24 ms 2692 KB Output is correct
50 Correct 25 ms 2644 KB Output is correct
51 Correct 222 ms 4448 KB Output is correct
52 Correct 4 ms 1184 KB Output is correct
53 Correct 387 ms 4988 KB Output is correct
54 Correct 430 ms 4964 KB Output is correct
55 Correct 5 ms 1236 KB Output is correct
56 Correct 4 ms 1236 KB Output is correct
57 Correct 1 ms 724 KB Output is correct
58 Correct 393 ms 4976 KB Output is correct
59 Correct 11 ms 1748 KB Output is correct
60 Correct 7 ms 1236 KB Output is correct
61 Correct 8 ms 1748 KB Output is correct
62 Correct 8 ms 1748 KB Output is correct
63 Correct 59 ms 2596 KB Output is correct
64 Correct 33 ms 2388 KB Output is correct
65 Correct 8 ms 1620 KB Output is correct
66 Correct 9 ms 1748 KB Output is correct
67 Correct 51 ms 3028 KB Output is correct
68 Correct 34 ms 2368 KB Output is correct
69 Correct 8 ms 1620 KB Output is correct
70 Correct 23 ms 2388 KB Output is correct
71 Correct 50 ms 2940 KB Output is correct
72 Correct 43 ms 2956 KB Output is correct
73 Correct 5 ms 1236 KB Output is correct
74 Correct 21 ms 2516 KB Output is correct
75 Correct 41 ms 3000 KB Output is correct
76 Correct 13 ms 2004 KB Output is correct
77 Correct 87 ms 3412 KB Output is correct
78 Correct 4 ms 1236 KB Output is correct
79 Correct 42 ms 1888 KB Output is correct
80 Correct 13 ms 2072 KB Output is correct
81 Correct 83 ms 3412 KB Output is correct
82 Correct 2 ms 596 KB Output is correct
83 Correct 47 ms 1876 KB Output is correct
84 Correct 41 ms 2900 KB Output is correct
85 Correct 2 ms 596 KB Output is correct
86 Incorrect 41 ms 2900 KB Output isn't correct
87 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 4 ms 1236 KB Output is correct
7 Correct 4 ms 1236 KB Output is correct
8 Correct 2 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 0 ms 212 KB Output is correct
14 Correct 4 ms 1236 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 5 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 5 ms 1044 KB Output is correct
21 Correct 2 ms 980 KB Output is correct
22 Correct 2 ms 724 KB Output is correct
23 Correct 6 ms 1364 KB Output is correct
24 Correct 1 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 7 ms 1236 KB Output is correct
28 Correct 6 ms 1236 KB Output is correct
29 Correct 6 ms 1236 KB Output is correct
30 Correct 7 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 8 ms 1364 KB Output is correct
34 Correct 8 ms 1364 KB Output is correct
35 Correct 4 ms 880 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 2 ms 596 KB Output is correct
40 Correct 9 ms 1748 KB Output is correct
41 Correct 2 ms 596 KB Output is correct
42 Correct 9 ms 1704 KB Output is correct
43 Correct 9 ms 1748 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 205 ms 19404 KB Output is correct
46 Correct 83 ms 12340 KB Output is correct
47 Correct 203 ms 19272 KB Output is correct
48 Correct 202 ms 19160 KB Output is correct
49 Correct 57 ms 9904 KB Output is correct
50 Correct 237 ms 23996 KB Output is correct
51 Correct 207 ms 19272 KB Output is correct
52 Correct 57 ms 9900 KB Output is correct
53 Correct 65 ms 9904 KB Output is correct
54 Correct 13 ms 5216 KB Output is correct
55 Correct 253 ms 23992 KB Output is correct
56 Correct 32 ms 7560 KB Output is correct
57 Correct 49 ms 9904 KB Output is correct
58 Correct 74 ms 12256 KB Output is correct
59 Correct 34 ms 7504 KB Output is correct
60 Correct 30 ms 7508 KB Output is correct
61 Correct 80 ms 12308 KB Output is correct
62 Correct 50 ms 9900 KB Output is correct
63 Correct 103 ms 13304 KB Output is correct
64 Correct 32 ms 7492 KB Output is correct
65 Correct 153 ms 15784 KB Output is correct
66 Correct 54 ms 9908 KB Output is correct
67 Correct 114 ms 13388 KB Output is correct
68 Correct 139 ms 15160 KB Output is correct
69 Correct 157 ms 15764 KB Output is correct
70 Correct 54 ms 9896 KB Output is correct
71 Correct 169 ms 15204 KB Output is correct
72 Correct 129 ms 12920 KB Output is correct
73 Correct 204 ms 17268 KB Output is correct
74 Correct 71 ms 9884 KB Output is correct
75 Correct 65 ms 7352 KB Output is correct
76 Correct 109 ms 13028 KB Output is correct
77 Correct 183 ms 17248 KB Output is correct
78 Correct 103 ms 8912 KB Output is correct
79 Correct 63 ms 7396 KB Output is correct
80 Correct 24 ms 3908 KB Output is correct
81 Correct 83 ms 8876 KB Output is correct
82 Correct 122 ms 14680 KB Output is correct
83 Correct 25 ms 3924 KB Output is correct
84 Incorrect 124 ms 14736 KB Output isn't correct
85 Halted 0 ms 0 KB -