답안 #1064365

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1064365 2024-08-18T11:53:49 Z turska Political Development (BOI17_politicaldevelopment) C++17
100 / 100
2537 ms 74216 KB
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


using ll = long long;
using ull = unsigned long long;
using ld = long double;

using pii = pair<int, int>;
using pll = pair<ll, ll>;

// const ll M = 998244353;
const ll M = 1e9 + 7;

#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second

const ll INFL = 1e18;
const int INF = 1e9;
const int maxN = 50000;

bool dp[maxN][1<<10];
set<int> adj[maxN];
void solve() {
    int n, k;
    cin >> n >> k;
    for (int i=0; i<n; i++) {
        int d;
        cin >> d;
        for (int j=0; j<d; j++) {
            int x;
            cin >> x;
            adj[i].insert(x);
        }
    }
    vector<int> ord(n);
    iota(all(ord), 0);
    sort(all(ord), [](int l, int r) {
        return adj[l].size() < adj[r].size();
    });
    int ans = 1;
    for (auto i : ord) {
        vector<int> cur;
        for (auto v: adj[i]) cur.push_back(v);
        dp[i][0] = true;
    
        for (int msk=1; msk<1<<cur.size(); msk++) {
            int p = __lg(msk);
            bool ok = dp[i][msk^(1<<p)];

            for (int j=0; j<p; j++) {
                if (!(msk&(1<<j))) continue;
                ok &= adj[cur[j]].count(cur[p]);
            }
            dp[i][msk] = ok;

            if (ok) {
                ans = max(ans, __builtin_popcount(msk)+1);
            }
        }
        for (auto v: cur) adj[v].erase(i);

    }
    cout << ans << '\n';
    
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    // cout << setprecision(12);

    int tc = 1;
    // cin >> tc;
    while (tc--) solve();

}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 6 ms 8284 KB Output is correct
4 Correct 4 ms 8280 KB Output is correct
5 Correct 4 ms 8284 KB Output is correct
6 Correct 5 ms 8284 KB Output is correct
7 Correct 7 ms 8368 KB Output is correct
8 Correct 3 ms 7772 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 3 ms 7772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 6 ms 8284 KB Output is correct
4 Correct 4 ms 8280 KB Output is correct
5 Correct 4 ms 8284 KB Output is correct
6 Correct 5 ms 8284 KB Output is correct
7 Correct 7 ms 8368 KB Output is correct
8 Correct 3 ms 7772 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 3 ms 7772 KB Output is correct
11 Correct 5 ms 8284 KB Output is correct
12 Correct 5 ms 8284 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 5 ms 8284 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 5 ms 8284 KB Output is correct
17 Correct 2 ms 2652 KB Output is correct
18 Correct 5 ms 8200 KB Output is correct
19 Correct 3 ms 7772 KB Output is correct
20 Correct 4 ms 8028 KB Output is correct
21 Correct 4 ms 8084 KB Output is correct
22 Correct 3 ms 7772 KB Output is correct
23 Correct 5 ms 8472 KB Output is correct
24 Correct 4 ms 7772 KB Output is correct
25 Correct 6 ms 8352 KB Output is correct
26 Correct 6 ms 8400 KB Output is correct
27 Correct 5 ms 8204 KB Output is correct
28 Correct 5 ms 8284 KB Output is correct
29 Correct 5 ms 8160 KB Output is correct
30 Correct 6 ms 8540 KB Output is correct
31 Correct 6 ms 8284 KB Output is correct
32 Correct 6 ms 8356 KB Output is correct
33 Correct 5 ms 8284 KB Output is correct
34 Correct 6 ms 8404 KB Output is correct
35 Correct 3 ms 5468 KB Output is correct
36 Correct 3 ms 5720 KB Output is correct
37 Correct 3 ms 5468 KB Output is correct
38 Correct 2 ms 4188 KB Output is correct
39 Correct 2 ms 4188 KB Output is correct
40 Correct 6 ms 8796 KB Output is correct
41 Correct 3 ms 4188 KB Output is correct
42 Correct 8 ms 8796 KB Output is correct
43 Correct 8 ms 8772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7772 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 2 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2648 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 398 ms 74200 KB Output is correct
12 Correct 1 ms 2648 KB Output is correct
13 Correct 378 ms 74204 KB Output is correct
14 Correct 1 ms 2648 KB Output is correct
15 Correct 400 ms 74068 KB Output is correct
16 Correct 384 ms 74008 KB Output is correct
17 Correct 368 ms 74208 KB Output is correct
18 Correct 373 ms 74068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 6 ms 8284 KB Output is correct
4 Correct 4 ms 8280 KB Output is correct
5 Correct 4 ms 8284 KB Output is correct
6 Correct 5 ms 8284 KB Output is correct
7 Correct 7 ms 8368 KB Output is correct
8 Correct 3 ms 7772 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 3 ms 7772 KB Output is correct
11 Correct 5 ms 8284 KB Output is correct
12 Correct 5 ms 8284 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 5 ms 8284 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 5 ms 8284 KB Output is correct
17 Correct 2 ms 2652 KB Output is correct
18 Correct 5 ms 8200 KB Output is correct
19 Correct 3 ms 7772 KB Output is correct
20 Correct 4 ms 8028 KB Output is correct
21 Correct 4 ms 8084 KB Output is correct
22 Correct 3 ms 7772 KB Output is correct
23 Correct 5 ms 8472 KB Output is correct
24 Correct 4 ms 7772 KB Output is correct
25 Correct 6 ms 8352 KB Output is correct
26 Correct 6 ms 8400 KB Output is correct
27 Correct 5 ms 8204 KB Output is correct
28 Correct 5 ms 8284 KB Output is correct
29 Correct 5 ms 8160 KB Output is correct
30 Correct 6 ms 8540 KB Output is correct
31 Correct 6 ms 8284 KB Output is correct
32 Correct 6 ms 8356 KB Output is correct
33 Correct 5 ms 8284 KB Output is correct
34 Correct 6 ms 8404 KB Output is correct
35 Correct 3 ms 5468 KB Output is correct
36 Correct 3 ms 5720 KB Output is correct
37 Correct 3 ms 5468 KB Output is correct
38 Correct 2 ms 4188 KB Output is correct
39 Correct 2 ms 4188 KB Output is correct
40 Correct 6 ms 8796 KB Output is correct
41 Correct 3 ms 4188 KB Output is correct
42 Correct 8 ms 8796 KB Output is correct
43 Correct 8 ms 8772 KB Output is correct
44 Correct 20 ms 9820 KB Output is correct
45 Correct 1 ms 2652 KB Output is correct
46 Correct 7 ms 8796 KB Output is correct
47 Correct 16 ms 9872 KB Output is correct
48 Correct 8 ms 8796 KB Output is correct
49 Correct 17 ms 9832 KB Output is correct
50 Correct 18 ms 9820 KB Output is correct
51 Correct 442 ms 11884 KB Output is correct
52 Correct 5 ms 8284 KB Output is correct
53 Correct 139 ms 12284 KB Output is correct
54 Correct 2537 ms 27732 KB Output is correct
55 Correct 5 ms 8284 KB Output is correct
56 Correct 4 ms 8284 KB Output is correct
57 Correct 3 ms 7772 KB Output is correct
58 Correct 131 ms 12372 KB Output is correct
59 Correct 6 ms 8796 KB Output is correct
60 Correct 5 ms 8284 KB Output is correct
61 Correct 6 ms 8796 KB Output is correct
62 Correct 6 ms 8796 KB Output is correct
63 Correct 19 ms 9736 KB Output is correct
64 Correct 13 ms 9564 KB Output is correct
65 Correct 7 ms 8540 KB Output is correct
66 Correct 6 ms 8840 KB Output is correct
67 Correct 32 ms 10324 KB Output is correct
68 Correct 13 ms 9564 KB Output is correct
69 Correct 7 ms 8540 KB Output is correct
70 Correct 13 ms 9564 KB Output is correct
71 Correct 32 ms 10228 KB Output is correct
72 Correct 28 ms 10068 KB Output is correct
73 Correct 5 ms 8284 KB Output is correct
74 Correct 15 ms 9564 KB Output is correct
75 Correct 32 ms 10188 KB Output is correct
76 Correct 12 ms 9052 KB Output is correct
77 Correct 67 ms 10548 KB Output is correct
78 Correct 5 ms 8284 KB Output is correct
79 Correct 34 ms 6804 KB Output is correct
80 Correct 11 ms 9052 KB Output is correct
81 Correct 69 ms 10712 KB Output is correct
82 Correct 2 ms 4188 KB Output is correct
83 Correct 34 ms 6576 KB Output is correct
84 Correct 39 ms 9984 KB Output is correct
85 Correct 4 ms 4188 KB Output is correct
86 Correct 36 ms 10068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 6 ms 8284 KB Output is correct
4 Correct 4 ms 8280 KB Output is correct
5 Correct 4 ms 8284 KB Output is correct
6 Correct 5 ms 8284 KB Output is correct
7 Correct 7 ms 8368 KB Output is correct
8 Correct 3 ms 7772 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 3 ms 7772 KB Output is correct
11 Correct 5 ms 8284 KB Output is correct
12 Correct 5 ms 8284 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 5 ms 8284 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 5 ms 8284 KB Output is correct
17 Correct 2 ms 2652 KB Output is correct
18 Correct 5 ms 8200 KB Output is correct
19 Correct 3 ms 7772 KB Output is correct
20 Correct 4 ms 8028 KB Output is correct
21 Correct 4 ms 8084 KB Output is correct
22 Correct 3 ms 7772 KB Output is correct
23 Correct 5 ms 8472 KB Output is correct
24 Correct 4 ms 7772 KB Output is correct
25 Correct 6 ms 8352 KB Output is correct
26 Correct 6 ms 8400 KB Output is correct
27 Correct 5 ms 8204 KB Output is correct
28 Correct 5 ms 8284 KB Output is correct
29 Correct 5 ms 8160 KB Output is correct
30 Correct 6 ms 8540 KB Output is correct
31 Correct 6 ms 8284 KB Output is correct
32 Correct 6 ms 8356 KB Output is correct
33 Correct 5 ms 8284 KB Output is correct
34 Correct 6 ms 8404 KB Output is correct
35 Correct 3 ms 5468 KB Output is correct
36 Correct 3 ms 5720 KB Output is correct
37 Correct 3 ms 5468 KB Output is correct
38 Correct 2 ms 4188 KB Output is correct
39 Correct 2 ms 4188 KB Output is correct
40 Correct 6 ms 8796 KB Output is correct
41 Correct 3 ms 4188 KB Output is correct
42 Correct 8 ms 8796 KB Output is correct
43 Correct 8 ms 8772 KB Output is correct
44 Correct 1 ms 2652 KB Output is correct
45 Correct 91 ms 68940 KB Output is correct
46 Correct 56 ms 61012 KB Output is correct
47 Correct 100 ms 68944 KB Output is correct
48 Correct 96 ms 68948 KB Output is correct
49 Correct 46 ms 58456 KB Output is correct
50 Correct 154 ms 74216 KB Output is correct
51 Correct 105 ms 68944 KB Output is correct
52 Correct 41 ms 58348 KB Output is correct
53 Correct 46 ms 58440 KB Output is correct
54 Correct 20 ms 53084 KB Output is correct
55 Correct 126 ms 74060 KB Output is correct
56 Correct 28 ms 55636 KB Output is correct
57 Correct 41 ms 58452 KB Output is correct
58 Correct 45 ms 61012 KB Output is correct
59 Correct 28 ms 55636 KB Output is correct
60 Correct 30 ms 55832 KB Output is correct
61 Correct 60 ms 60984 KB Output is correct
62 Correct 41 ms 58448 KB Output is correct
63 Correct 55 ms 62296 KB Output is correct
64 Correct 34 ms 55620 KB Output is correct
65 Correct 84 ms 64812 KB Output is correct
66 Correct 42 ms 58256 KB Output is correct
67 Correct 59 ms 62292 KB Output is correct
68 Correct 74 ms 64340 KB Output is correct
69 Correct 72 ms 64932 KB Output is correct
70 Correct 35 ms 58324 KB Output is correct
71 Correct 70 ms 64348 KB Output is correct
72 Correct 61 ms 61780 KB Output is correct
73 Correct 80 ms 66644 KB Output is correct
74 Correct 40 ms 58460 KB Output is correct
75 Correct 29 ms 32852 KB Output is correct
76 Correct 60 ms 61780 KB Output is correct
77 Correct 79 ms 66700 KB Output is correct
78 Correct 40 ms 34644 KB Output is correct
79 Correct 38 ms 32852 KB Output is correct
80 Correct 17 ms 17756 KB Output is correct
81 Correct 42 ms 34644 KB Output is correct
82 Correct 59 ms 63572 KB Output is correct
83 Correct 17 ms 17756 KB Output is correct
84 Correct 66 ms 63572 KB Output is correct