Submission #981804

# Submission time Handle Problem Language Result Execution time Memory
981804 2024-05-13T15:10:23 Z Ghulam_Junaid Political Development (BOI17_politicaldevelopment) C++17
100 / 100
346 ms 28576 KB
#include <bits/stdc++.h>
using namespace std;
 
const int N = 5e4 + 10;
int n, k;
unordered_set<int> g[N];
set<pair<int, int>> st;
 
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
 
    cin >> n >> k;
 
    for (int i = 0; i < n; i ++){
        int x;
        cin >> x;
 
        for (int j = 0; j < x; j ++){
            int v;
            cin >> v;
            g[i].insert(v);
        }
 
        st.insert({x, i});
    }
 
    int ans = 1;
    while (!st.empty()){
        auto p = *st.begin();
        st.erase(st.begin());
 
        int v = p.second;
 
        vector<int> possible;
        for (int u : g[v])
            possible.push_back(u);
 
        int sz = possible.size();
 
        for (int mask = 0; mask < (1 << sz); mask ++){
            vector<int> appeared;       
            bool good = 1;     
            for (int i = 0; i < sz; i ++){
                if ((1 << i) & mask == 0) continue;
 
                bool all = 1;
                for (int x : appeared)
                    if (g[possible[i]].find(x) == g[possible[i]].end())
                        all = 0;
 
                if (!all){
                    good = 0;
                    break;
                }
 
                appeared.push_back(possible[i]);
            }
 
            if (good)
                ans = max(ans, (int)appeared.size() + 1);
        }
 
        for (int u : possible){
            st.erase({g[u].size(), u});
            g[u].erase(v);
            st.insert({g[u].size(), u});
        }
    }
 
    cout << ans << endl;
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:45:37: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   45 |                 if ((1 << i) & mask == 0) continue;
      |                                ~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3164 KB Output is correct
2 Correct 2 ms 3164 KB Output is correct
3 Correct 5 ms 4188 KB Output is correct
4 Correct 4 ms 4188 KB Output is correct
5 Correct 6 ms 4188 KB Output is correct
6 Correct 5 ms 4188 KB Output is correct
7 Correct 5 ms 4188 KB Output is correct
8 Correct 2 ms 3420 KB Output is correct
9 Correct 1 ms 3164 KB Output is correct
10 Correct 3 ms 3208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3164 KB Output is correct
2 Correct 2 ms 3164 KB Output is correct
3 Correct 5 ms 4188 KB Output is correct
4 Correct 4 ms 4188 KB Output is correct
5 Correct 6 ms 4188 KB Output is correct
6 Correct 5 ms 4188 KB Output is correct
7 Correct 5 ms 4188 KB Output is correct
8 Correct 2 ms 3420 KB Output is correct
9 Correct 1 ms 3164 KB Output is correct
10 Correct 3 ms 3208 KB Output is correct
11 Correct 5 ms 4188 KB Output is correct
12 Correct 5 ms 4236 KB Output is correct
13 Correct 1 ms 3164 KB Output is correct
14 Correct 4 ms 4188 KB Output is correct
15 Correct 2 ms 3164 KB Output is correct
16 Correct 6 ms 4188 KB Output is correct
17 Correct 1 ms 3164 KB Output is correct
18 Correct 7 ms 4188 KB Output is correct
19 Correct 2 ms 3420 KB Output is correct
20 Correct 4 ms 3932 KB Output is correct
21 Correct 4 ms 3932 KB Output is correct
22 Correct 2 ms 3212 KB Output is correct
23 Correct 6 ms 4240 KB Output is correct
24 Correct 2 ms 3420 KB Output is correct
25 Correct 9 ms 4444 KB Output is correct
26 Correct 5 ms 4188 KB Output is correct
27 Correct 4 ms 4188 KB Output is correct
28 Correct 6 ms 4188 KB Output is correct
29 Correct 4 ms 4188 KB Output is correct
30 Correct 6 ms 4360 KB Output is correct
31 Correct 6 ms 4444 KB Output is correct
32 Correct 5 ms 4444 KB Output is correct
33 Correct 6 ms 4444 KB Output is correct
34 Correct 6 ms 4468 KB Output is correct
35 Correct 4 ms 3676 KB Output is correct
36 Correct 3 ms 3676 KB Output is correct
37 Correct 3 ms 3676 KB Output is correct
38 Correct 3 ms 3420 KB Output is correct
39 Correct 3 ms 3420 KB Output is correct
40 Correct 8 ms 4588 KB Output is correct
41 Correct 4 ms 3420 KB Output is correct
42 Correct 8 ms 4720 KB Output is correct
43 Correct 8 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3204 KB Output is correct
2 Correct 1 ms 3164 KB Output is correct
3 Correct 2 ms 3164 KB Output is correct
4 Correct 2 ms 3164 KB Output is correct
5 Correct 2 ms 3164 KB Output is correct
6 Correct 1 ms 3164 KB Output is correct
7 Correct 1 ms 3164 KB Output is correct
8 Correct 1 ms 3164 KB Output is correct
9 Correct 2 ms 3164 KB Output is correct
10 Correct 1 ms 3164 KB Output is correct
11 Correct 289 ms 27740 KB Output is correct
12 Correct 2 ms 3164 KB Output is correct
13 Correct 289 ms 27744 KB Output is correct
14 Correct 2 ms 3164 KB Output is correct
15 Correct 302 ms 27724 KB Output is correct
16 Correct 327 ms 27564 KB Output is correct
17 Correct 315 ms 27692 KB Output is correct
18 Correct 346 ms 27744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3164 KB Output is correct
2 Correct 2 ms 3164 KB Output is correct
3 Correct 5 ms 4188 KB Output is correct
4 Correct 4 ms 4188 KB Output is correct
5 Correct 6 ms 4188 KB Output is correct
6 Correct 5 ms 4188 KB Output is correct
7 Correct 5 ms 4188 KB Output is correct
8 Correct 2 ms 3420 KB Output is correct
9 Correct 1 ms 3164 KB Output is correct
10 Correct 3 ms 3208 KB Output is correct
11 Correct 5 ms 4188 KB Output is correct
12 Correct 5 ms 4236 KB Output is correct
13 Correct 1 ms 3164 KB Output is correct
14 Correct 4 ms 4188 KB Output is correct
15 Correct 2 ms 3164 KB Output is correct
16 Correct 6 ms 4188 KB Output is correct
17 Correct 1 ms 3164 KB Output is correct
18 Correct 7 ms 4188 KB Output is correct
19 Correct 2 ms 3420 KB Output is correct
20 Correct 4 ms 3932 KB Output is correct
21 Correct 4 ms 3932 KB Output is correct
22 Correct 2 ms 3212 KB Output is correct
23 Correct 6 ms 4240 KB Output is correct
24 Correct 2 ms 3420 KB Output is correct
25 Correct 9 ms 4444 KB Output is correct
26 Correct 5 ms 4188 KB Output is correct
27 Correct 4 ms 4188 KB Output is correct
28 Correct 6 ms 4188 KB Output is correct
29 Correct 4 ms 4188 KB Output is correct
30 Correct 6 ms 4360 KB Output is correct
31 Correct 6 ms 4444 KB Output is correct
32 Correct 5 ms 4444 KB Output is correct
33 Correct 6 ms 4444 KB Output is correct
34 Correct 6 ms 4468 KB Output is correct
35 Correct 4 ms 3676 KB Output is correct
36 Correct 3 ms 3676 KB Output is correct
37 Correct 3 ms 3676 KB Output is correct
38 Correct 3 ms 3420 KB Output is correct
39 Correct 3 ms 3420 KB Output is correct
40 Correct 8 ms 4588 KB Output is correct
41 Correct 4 ms 3420 KB Output is correct
42 Correct 8 ms 4720 KB Output is correct
43 Correct 8 ms 4700 KB Output is correct
44 Correct 69 ms 5408 KB Output is correct
45 Correct 1 ms 3164 KB Output is correct
46 Correct 12 ms 4716 KB Output is correct
47 Correct 16 ms 5500 KB Output is correct
48 Correct 8 ms 4700 KB Output is correct
49 Correct 19 ms 5468 KB Output is correct
50 Correct 17 ms 5468 KB Output is correct
51 Correct 58 ms 7456 KB Output is correct
52 Correct 4 ms 4400 KB Output is correct
53 Correct 73 ms 7516 KB Output is correct
54 Correct 93 ms 7724 KB Output is correct
55 Correct 5 ms 4188 KB Output is correct
56 Correct 6 ms 4188 KB Output is correct
57 Correct 2 ms 3424 KB Output is correct
58 Correct 75 ms 7340 KB Output is correct
59 Correct 8 ms 4700 KB Output is correct
60 Correct 7 ms 4188 KB Output is correct
61 Correct 9 ms 4700 KB Output is correct
62 Correct 9 ms 4700 KB Output is correct
63 Correct 70 ms 5212 KB Output is correct
64 Correct 41 ms 5236 KB Output is correct
65 Correct 7 ms 4444 KB Output is correct
66 Correct 9 ms 4700 KB Output is correct
67 Correct 35 ms 5724 KB Output is correct
68 Correct 35 ms 5252 KB Output is correct
69 Correct 8 ms 4444 KB Output is correct
70 Correct 17 ms 5212 KB Output is correct
71 Correct 39 ms 5812 KB Output is correct
72 Correct 38 ms 5724 KB Output is correct
73 Correct 6 ms 4188 KB Output is correct
74 Correct 17 ms 5100 KB Output is correct
75 Correct 37 ms 5724 KB Output is correct
76 Correct 10 ms 4956 KB Output is correct
77 Correct 31 ms 6024 KB Output is correct
78 Correct 7 ms 4188 KB Output is correct
79 Correct 22 ms 4444 KB Output is correct
80 Correct 11 ms 4956 KB Output is correct
81 Correct 31 ms 6168 KB Output is correct
82 Correct 3 ms 3420 KB Output is correct
83 Correct 15 ms 4444 KB Output is correct
84 Correct 20 ms 5468 KB Output is correct
85 Correct 3 ms 3420 KB Output is correct
86 Correct 20 ms 5612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3164 KB Output is correct
2 Correct 2 ms 3164 KB Output is correct
3 Correct 5 ms 4188 KB Output is correct
4 Correct 4 ms 4188 KB Output is correct
5 Correct 6 ms 4188 KB Output is correct
6 Correct 5 ms 4188 KB Output is correct
7 Correct 5 ms 4188 KB Output is correct
8 Correct 2 ms 3420 KB Output is correct
9 Correct 1 ms 3164 KB Output is correct
10 Correct 3 ms 3208 KB Output is correct
11 Correct 5 ms 4188 KB Output is correct
12 Correct 5 ms 4236 KB Output is correct
13 Correct 1 ms 3164 KB Output is correct
14 Correct 4 ms 4188 KB Output is correct
15 Correct 2 ms 3164 KB Output is correct
16 Correct 6 ms 4188 KB Output is correct
17 Correct 1 ms 3164 KB Output is correct
18 Correct 7 ms 4188 KB Output is correct
19 Correct 2 ms 3420 KB Output is correct
20 Correct 4 ms 3932 KB Output is correct
21 Correct 4 ms 3932 KB Output is correct
22 Correct 2 ms 3212 KB Output is correct
23 Correct 6 ms 4240 KB Output is correct
24 Correct 2 ms 3420 KB Output is correct
25 Correct 9 ms 4444 KB Output is correct
26 Correct 5 ms 4188 KB Output is correct
27 Correct 4 ms 4188 KB Output is correct
28 Correct 6 ms 4188 KB Output is correct
29 Correct 4 ms 4188 KB Output is correct
30 Correct 6 ms 4360 KB Output is correct
31 Correct 6 ms 4444 KB Output is correct
32 Correct 5 ms 4444 KB Output is correct
33 Correct 6 ms 4444 KB Output is correct
34 Correct 6 ms 4468 KB Output is correct
35 Correct 4 ms 3676 KB Output is correct
36 Correct 3 ms 3676 KB Output is correct
37 Correct 3 ms 3676 KB Output is correct
38 Correct 3 ms 3420 KB Output is correct
39 Correct 3 ms 3420 KB Output is correct
40 Correct 8 ms 4588 KB Output is correct
41 Correct 4 ms 3420 KB Output is correct
42 Correct 8 ms 4720 KB Output is correct
43 Correct 8 ms 4700 KB Output is correct
44 Correct 2 ms 3164 KB Output is correct
45 Correct 173 ms 22348 KB Output is correct
46 Correct 74 ms 16980 KB Output is correct
47 Correct 175 ms 22496 KB Output is correct
48 Correct 177 ms 22612 KB Output is correct
49 Correct 42 ms 15468 KB Output is correct
50 Correct 143 ms 28576 KB Output is correct
51 Correct 197 ms 22356 KB Output is correct
52 Correct 45 ms 15196 KB Output is correct
53 Correct 43 ms 15612 KB Output is correct
54 Correct 10 ms 5468 KB Output is correct
55 Correct 136 ms 28540 KB Output is correct
56 Correct 39 ms 12892 KB Output is correct
57 Correct 56 ms 15232 KB Output is correct
58 Correct 68 ms 16648 KB Output is correct
59 Correct 45 ms 12720 KB Output is correct
60 Correct 32 ms 12940 KB Output is correct
61 Correct 79 ms 16628 KB Output is correct
62 Correct 52 ms 14684 KB Output is correct
63 Correct 136 ms 17572 KB Output is correct
64 Correct 43 ms 12884 KB Output is correct
65 Correct 120 ms 19432 KB Output is correct
66 Correct 47 ms 14796 KB Output is correct
67 Correct 111 ms 17492 KB Output is correct
68 Correct 131 ms 18964 KB Output is correct
69 Correct 127 ms 19648 KB Output is correct
70 Correct 49 ms 14800 KB Output is correct
71 Correct 143 ms 18976 KB Output is correct
72 Correct 83 ms 17620 KB Output is correct
73 Correct 154 ms 20564 KB Output is correct
74 Correct 57 ms 14800 KB Output is correct
75 Correct 56 ms 10728 KB Output is correct
76 Correct 98 ms 17612 KB Output is correct
77 Correct 159 ms 20604 KB Output is correct
78 Correct 62 ms 11868 KB Output is correct
79 Correct 55 ms 10580 KB Output is correct
80 Correct 19 ms 7004 KB Output is correct
81 Correct 71 ms 11860 KB Output is correct
82 Correct 137 ms 18504 KB Output is correct
83 Correct 20 ms 7004 KB Output is correct
84 Correct 115 ms 18496 KB Output is correct