Submission #557540

# Submission time Handle Problem Language Result Execution time Memory
557540 2022-05-05T12:47:05 Z fatemetmhr Political Development (BOI17_politicaldevelopment) C++17
100 / 100
339 ms 41704 KB
// `Be name khoda` //

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pb     push_back
#define all(x) x.begin(), x.end()
#define fi     first
#define se     second


const int maxn5 = 2e5 + 10;

set <int> adjset[maxn5];
vector <int> adj[maxn5], ver;
priority_queue <pair<int, int>> av;
bool ed[20][20], mark[maxn5], dp[1 << 20];
int cnt[maxn5];

inline int max_indep(){
    int n = ver.size();
    assert(n <= 10);
    memset(ed, false, sizeof ed);
    for(int i = 0; i < n; i++) for(int j = 0; j < n; j++)
        if(adjset[ver[i]].find(ver[j]) != adjset[ver[i]].end())
            ed[i][j] = true;
    dp[0] = true;
    int ans = 0;
    for(int mask = 1; mask < (1 << n); mask++){
        int v = -1;
        dp[mask] = true;
        for(int i = 0; i < n; i++) if((mask >> i)&1){
            if(v == -1){
                v = i;
                dp[mask] = dp[mask ^ (1 << i)];
            }
            else
                dp[mask] &= ed[v][i];
        }
        if(dp[mask])
            ans = max(ans, __builtin_popcount(mask));
    }
    return ans;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int n, k; cin >> n >> k;
    for(int i = 0; i < n; i++){
        int l; cin >> l;
        cnt[i] = l;
        while(l--){
            int a; cin >> a;
            adj[i].pb(a);
            adjset[i].insert(a);
            assert(a != i);
        }
        av.push({-cnt[i], i});
    }
    for(int i = 0; i < n; i++) for(auto u : adj[i])
        assert(adjset[u].find(i) != adjset[u].end());
    int ans = 0;
    for(int i = 0; i < n; i++){
        while(mark[av.top().se])
            av.pop();
        int v = av.top().se;
        av.pop();
        mark[v] = true;
        ver.clear();
        for(auto u : adj[v]) if(!mark[u]){
            cnt[u]--;
            av.push({-cnt[u], u});
            ver.pb(u);
        }
        ans = max(ans, max_indep() + 1);
    }
    cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14420 KB Output is correct
2 Correct 8 ms 14292 KB Output is correct
3 Correct 11 ms 15060 KB Output is correct
4 Correct 10 ms 15060 KB Output is correct
5 Correct 11 ms 15060 KB Output is correct
6 Correct 11 ms 15140 KB Output is correct
7 Correct 10 ms 15060 KB Output is correct
8 Correct 10 ms 14544 KB Output is correct
9 Correct 7 ms 14420 KB Output is correct
10 Correct 8 ms 14548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14420 KB Output is correct
2 Correct 8 ms 14292 KB Output is correct
3 Correct 11 ms 15060 KB Output is correct
4 Correct 10 ms 15060 KB Output is correct
5 Correct 11 ms 15060 KB Output is correct
6 Correct 11 ms 15140 KB Output is correct
7 Correct 10 ms 15060 KB Output is correct
8 Correct 10 ms 14544 KB Output is correct
9 Correct 7 ms 14420 KB Output is correct
10 Correct 8 ms 14548 KB Output is correct
11 Correct 12 ms 15116 KB Output is correct
12 Correct 11 ms 15048 KB Output is correct
13 Correct 7 ms 14304 KB Output is correct
14 Correct 11 ms 15060 KB Output is correct
15 Correct 8 ms 14420 KB Output is correct
16 Correct 16 ms 15056 KB Output is correct
17 Correct 8 ms 14420 KB Output is correct
18 Correct 10 ms 15060 KB Output is correct
19 Correct 9 ms 14548 KB Output is correct
20 Correct 10 ms 14848 KB Output is correct
21 Correct 10 ms 14888 KB Output is correct
22 Correct 11 ms 14548 KB Output is correct
23 Correct 17 ms 15180 KB Output is correct
24 Correct 8 ms 14552 KB Output is correct
25 Correct 11 ms 15244 KB Output is correct
26 Correct 12 ms 15188 KB Output is correct
27 Correct 15 ms 15040 KB Output is correct
28 Correct 11 ms 15060 KB Output is correct
29 Correct 12 ms 15060 KB Output is correct
30 Correct 16 ms 15212 KB Output is correct
31 Correct 11 ms 15280 KB Output is correct
32 Correct 11 ms 15220 KB Output is correct
33 Correct 12 ms 15188 KB Output is correct
34 Correct 19 ms 15224 KB Output is correct
35 Correct 9 ms 14804 KB Output is correct
36 Correct 10 ms 14800 KB Output is correct
37 Correct 9 ms 14804 KB Output is correct
38 Correct 9 ms 14676 KB Output is correct
39 Correct 13 ms 14688 KB Output is correct
40 Correct 15 ms 15828 KB Output is correct
41 Correct 9 ms 14676 KB Output is correct
42 Correct 15 ms 15764 KB Output is correct
43 Correct 15 ms 15828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14544 KB Output is correct
2 Correct 8 ms 14420 KB Output is correct
3 Correct 7 ms 14420 KB Output is correct
4 Correct 7 ms 14420 KB Output is correct
5 Correct 8 ms 14420 KB Output is correct
6 Correct 9 ms 14420 KB Output is correct
7 Correct 7 ms 14420 KB Output is correct
8 Correct 7 ms 14420 KB Output is correct
9 Correct 7 ms 14420 KB Output is correct
10 Correct 10 ms 14392 KB Output is correct
11 Correct 285 ms 41668 KB Output is correct
12 Correct 8 ms 14420 KB Output is correct
13 Correct 300 ms 41692 KB Output is correct
14 Correct 7 ms 14420 KB Output is correct
15 Correct 287 ms 41704 KB Output is correct
16 Correct 316 ms 41696 KB Output is correct
17 Correct 339 ms 41660 KB Output is correct
18 Correct 317 ms 41660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14420 KB Output is correct
2 Correct 8 ms 14292 KB Output is correct
3 Correct 11 ms 15060 KB Output is correct
4 Correct 10 ms 15060 KB Output is correct
5 Correct 11 ms 15060 KB Output is correct
6 Correct 11 ms 15140 KB Output is correct
7 Correct 10 ms 15060 KB Output is correct
8 Correct 10 ms 14544 KB Output is correct
9 Correct 7 ms 14420 KB Output is correct
10 Correct 8 ms 14548 KB Output is correct
11 Correct 12 ms 15116 KB Output is correct
12 Correct 11 ms 15048 KB Output is correct
13 Correct 7 ms 14304 KB Output is correct
14 Correct 11 ms 15060 KB Output is correct
15 Correct 8 ms 14420 KB Output is correct
16 Correct 16 ms 15056 KB Output is correct
17 Correct 8 ms 14420 KB Output is correct
18 Correct 10 ms 15060 KB Output is correct
19 Correct 9 ms 14548 KB Output is correct
20 Correct 10 ms 14848 KB Output is correct
21 Correct 10 ms 14888 KB Output is correct
22 Correct 11 ms 14548 KB Output is correct
23 Correct 17 ms 15180 KB Output is correct
24 Correct 8 ms 14552 KB Output is correct
25 Correct 11 ms 15244 KB Output is correct
26 Correct 12 ms 15188 KB Output is correct
27 Correct 15 ms 15040 KB Output is correct
28 Correct 11 ms 15060 KB Output is correct
29 Correct 12 ms 15060 KB Output is correct
30 Correct 16 ms 15212 KB Output is correct
31 Correct 11 ms 15280 KB Output is correct
32 Correct 11 ms 15220 KB Output is correct
33 Correct 12 ms 15188 KB Output is correct
34 Correct 19 ms 15224 KB Output is correct
35 Correct 9 ms 14804 KB Output is correct
36 Correct 10 ms 14800 KB Output is correct
37 Correct 9 ms 14804 KB Output is correct
38 Correct 9 ms 14676 KB Output is correct
39 Correct 13 ms 14688 KB Output is correct
40 Correct 15 ms 15828 KB Output is correct
41 Correct 9 ms 14676 KB Output is correct
42 Correct 15 ms 15764 KB Output is correct
43 Correct 15 ms 15828 KB Output is correct
44 Correct 34 ms 16796 KB Output is correct
45 Correct 9 ms 14340 KB Output is correct
46 Correct 17 ms 15780 KB Output is correct
47 Correct 26 ms 17108 KB Output is correct
48 Correct 20 ms 15724 KB Output is correct
49 Correct 26 ms 17108 KB Output is correct
50 Correct 32 ms 17096 KB Output is correct
51 Correct 71 ms 19696 KB Output is correct
52 Correct 12 ms 15208 KB Output is correct
53 Correct 103 ms 20224 KB Output is correct
54 Correct 110 ms 20264 KB Output is correct
55 Correct 12 ms 15188 KB Output is correct
56 Correct 14 ms 15204 KB Output is correct
57 Correct 10 ms 14548 KB Output is correct
58 Correct 104 ms 20228 KB Output is correct
59 Correct 19 ms 15656 KB Output is correct
60 Correct 12 ms 15188 KB Output is correct
61 Correct 15 ms 15588 KB Output is correct
62 Correct 16 ms 15640 KB Output is correct
63 Correct 30 ms 16724 KB Output is correct
64 Correct 25 ms 16544 KB Output is correct
65 Correct 14 ms 15576 KB Output is correct
66 Correct 16 ms 15640 KB Output is correct
67 Correct 42 ms 17540 KB Output is correct
68 Correct 25 ms 16484 KB Output is correct
69 Correct 16 ms 15576 KB Output is correct
70 Correct 23 ms 16728 KB Output is correct
71 Correct 33 ms 17408 KB Output is correct
72 Correct 32 ms 17456 KB Output is correct
73 Correct 12 ms 15084 KB Output is correct
74 Correct 27 ms 16808 KB Output is correct
75 Correct 29 ms 17476 KB Output is correct
76 Correct 18 ms 16124 KB Output is correct
77 Correct 46 ms 18128 KB Output is correct
78 Correct 14 ms 15072 KB Output is correct
79 Correct 24 ms 16340 KB Output is correct
80 Correct 18 ms 16212 KB Output is correct
81 Correct 39 ms 18092 KB Output is correct
82 Correct 10 ms 14728 KB Output is correct
83 Correct 23 ms 16328 KB Output is correct
84 Correct 33 ms 17436 KB Output is correct
85 Correct 10 ms 14688 KB Output is correct
86 Correct 27 ms 17484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14420 KB Output is correct
2 Correct 8 ms 14292 KB Output is correct
3 Correct 11 ms 15060 KB Output is correct
4 Correct 10 ms 15060 KB Output is correct
5 Correct 11 ms 15060 KB Output is correct
6 Correct 11 ms 15140 KB Output is correct
7 Correct 10 ms 15060 KB Output is correct
8 Correct 10 ms 14544 KB Output is correct
9 Correct 7 ms 14420 KB Output is correct
10 Correct 8 ms 14548 KB Output is correct
11 Correct 12 ms 15116 KB Output is correct
12 Correct 11 ms 15048 KB Output is correct
13 Correct 7 ms 14304 KB Output is correct
14 Correct 11 ms 15060 KB Output is correct
15 Correct 8 ms 14420 KB Output is correct
16 Correct 16 ms 15056 KB Output is correct
17 Correct 8 ms 14420 KB Output is correct
18 Correct 10 ms 15060 KB Output is correct
19 Correct 9 ms 14548 KB Output is correct
20 Correct 10 ms 14848 KB Output is correct
21 Correct 10 ms 14888 KB Output is correct
22 Correct 11 ms 14548 KB Output is correct
23 Correct 17 ms 15180 KB Output is correct
24 Correct 8 ms 14552 KB Output is correct
25 Correct 11 ms 15244 KB Output is correct
26 Correct 12 ms 15188 KB Output is correct
27 Correct 15 ms 15040 KB Output is correct
28 Correct 11 ms 15060 KB Output is correct
29 Correct 12 ms 15060 KB Output is correct
30 Correct 16 ms 15212 KB Output is correct
31 Correct 11 ms 15280 KB Output is correct
32 Correct 11 ms 15220 KB Output is correct
33 Correct 12 ms 15188 KB Output is correct
34 Correct 19 ms 15224 KB Output is correct
35 Correct 9 ms 14804 KB Output is correct
36 Correct 10 ms 14800 KB Output is correct
37 Correct 9 ms 14804 KB Output is correct
38 Correct 9 ms 14676 KB Output is correct
39 Correct 13 ms 14688 KB Output is correct
40 Correct 15 ms 15828 KB Output is correct
41 Correct 9 ms 14676 KB Output is correct
42 Correct 15 ms 15764 KB Output is correct
43 Correct 15 ms 15828 KB Output is correct
44 Correct 9 ms 14348 KB Output is correct
45 Correct 186 ms 33376 KB Output is correct
46 Correct 98 ms 24136 KB Output is correct
47 Correct 173 ms 33380 KB Output is correct
48 Correct 169 ms 33356 KB Output is correct
49 Correct 51 ms 21700 KB Output is correct
50 Correct 183 ms 38072 KB Output is correct
51 Correct 167 ms 33348 KB Output is correct
52 Correct 53 ms 22160 KB Output is correct
53 Correct 48 ms 22104 KB Output is correct
54 Correct 18 ms 15248 KB Output is correct
55 Correct 191 ms 40104 KB Output is correct
56 Correct 38 ms 19268 KB Output is correct
57 Correct 56 ms 22188 KB Output is correct
58 Correct 71 ms 24624 KB Output is correct
59 Correct 35 ms 19276 KB Output is correct
60 Correct 33 ms 19268 KB Output is correct
61 Correct 71 ms 24620 KB Output is correct
62 Correct 49 ms 21988 KB Output is correct
63 Correct 100 ms 26736 KB Output is correct
64 Correct 33 ms 19276 KB Output is correct
65 Correct 126 ms 29764 KB Output is correct
66 Correct 49 ms 21952 KB Output is correct
67 Correct 90 ms 26684 KB Output is correct
68 Correct 109 ms 28832 KB Output is correct
69 Correct 122 ms 29580 KB Output is correct
70 Correct 50 ms 21956 KB Output is correct
71 Correct 122 ms 28924 KB Output is correct
72 Correct 95 ms 26340 KB Output is correct
73 Correct 132 ms 31292 KB Output is correct
74 Correct 50 ms 21956 KB Output is correct
75 Correct 46 ms 21060 KB Output is correct
76 Correct 96 ms 26308 KB Output is correct
77 Correct 128 ms 31328 KB Output is correct
78 Correct 64 ms 22832 KB Output is correct
79 Correct 46 ms 21052 KB Output is correct
80 Correct 29 ms 17756 KB Output is correct
81 Correct 61 ms 22872 KB Output is correct
82 Correct 96 ms 27860 KB Output is correct
83 Correct 27 ms 17812 KB Output is correct
84 Correct 103 ms 27812 KB Output is correct