Submission #758389

# Submission time Handle Problem Language Result Execution time Memory
758389 2023-06-14T14:34:26 Z joelgun14 Political Development (BOI17_politicaldevelopment) C++17
100 / 100
1053 ms 33228 KB
#include <bits/stdc++.h>
#define endl "\n"
#define fi first
#define se second
using namespace std;
const int lim = 2e5 + 5;
set<int> edges[lim];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, k;
    cin >> n >> k;
    // fi -> cnt
    // se -> num
    set<pair<int, int>> s;
    for(int i = 0; i < n; ++i) {
        int d;
        cin >> d;
        for(int j = 0; j < d; ++j) {
            int x;
            cin >> x;
            edges[i].insert(x);
        }
        s.insert({d, i});
    }
    int mx = 0;
    //cout << "TEST" << endl;
    while(s.size()) {
        // smallest cnt
        // id nya sembarang
        int sz = (*s.begin()).fi, id = (*s.begin()).se;
        //cout << sz << " "<< id << endl;
        s.erase(s.begin());
        // nah berarti proses node ke id
        vector<int> adj;
        for(auto i : edges[id])
            adj.push_back(i);
        for(int i = 0; i < (1 << adj.size()); ++i) {
            vector<int> nodes = {id};
            for(int j = 0; j < adj.size(); ++j) {
                if((1 << j) & i) {
                    nodes.push_back(adj[j]);
                }
            }
            bool ans = 1;
            for(int j = 0; j < nodes.size(); ++j) {
                for(int k = j + 1; k < nodes.size(); ++k) {
                    if(!edges[nodes[j]].count(nodes[k])) {
                        ans = 0;
                    }
                }
            }
            if(ans)
                mx = max(mx, (int)nodes.size());
        }
        for(auto i : adj) {
            s.erase(s.find({edges[i].size(), i}));
            edges[i].erase(edges[i].find(id));
            s.insert({edges[i].size(), i});
        }
        edges[id].clear();
    }
    cout << mx << endl;
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:39:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |             for(int j = 0; j < adj.size(); ++j) {
      |                            ~~^~~~~~~~~~~~
politicaldevelopment.cpp:45:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |             for(int j = 0; j < nodes.size(); ++j) {
      |                            ~~^~~~~~~~~~~~~~
politicaldevelopment.cpp:46:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |                 for(int k = j + 1; k < nodes.size(); ++k) {
      |                                    ~~^~~~~~~~~~~~~~
politicaldevelopment.cpp:30:13: warning: unused variable 'sz' [-Wunused-variable]
   30 |         int sz = (*s.begin()).fi, id = (*s.begin()).se;
      |             ^~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9684 KB Output is correct
3 Correct 10 ms 10324 KB Output is correct
4 Correct 10 ms 10400 KB Output is correct
5 Correct 9 ms 10416 KB Output is correct
6 Correct 10 ms 10384 KB Output is correct
7 Correct 11 ms 10388 KB Output is correct
8 Correct 6 ms 9948 KB Output is correct
9 Correct 5 ms 9684 KB Output is correct
10 Correct 6 ms 9940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9684 KB Output is correct
3 Correct 10 ms 10324 KB Output is correct
4 Correct 10 ms 10400 KB Output is correct
5 Correct 9 ms 10416 KB Output is correct
6 Correct 10 ms 10384 KB Output is correct
7 Correct 11 ms 10388 KB Output is correct
8 Correct 6 ms 9948 KB Output is correct
9 Correct 5 ms 9684 KB Output is correct
10 Correct 6 ms 9940 KB Output is correct
11 Correct 10 ms 10324 KB Output is correct
12 Correct 9 ms 10324 KB Output is correct
13 Correct 5 ms 9684 KB Output is correct
14 Correct 11 ms 10324 KB Output is correct
15 Correct 6 ms 9684 KB Output is correct
16 Correct 11 ms 10324 KB Output is correct
17 Correct 5 ms 9684 KB Output is correct
18 Correct 10 ms 10324 KB Output is correct
19 Correct 7 ms 9940 KB Output is correct
20 Correct 8 ms 10068 KB Output is correct
21 Correct 8 ms 10068 KB Output is correct
22 Correct 6 ms 9940 KB Output is correct
23 Correct 10 ms 10420 KB Output is correct
24 Correct 7 ms 9948 KB Output is correct
25 Correct 11 ms 10452 KB Output is correct
26 Correct 12 ms 10452 KB Output is correct
27 Correct 13 ms 10428 KB Output is correct
28 Correct 11 ms 10452 KB Output is correct
29 Correct 13 ms 10324 KB Output is correct
30 Correct 12 ms 10576 KB Output is correct
31 Correct 11 ms 10452 KB Output is correct
32 Correct 11 ms 10580 KB Output is correct
33 Correct 11 ms 10580 KB Output is correct
34 Correct 12 ms 10572 KB Output is correct
35 Correct 9 ms 10068 KB Output is correct
36 Correct 10 ms 10068 KB Output is correct
37 Correct 8 ms 10068 KB Output is correct
38 Correct 7 ms 9940 KB Output is correct
39 Correct 7 ms 9940 KB Output is correct
40 Correct 16 ms 10836 KB Output is correct
41 Correct 8 ms 9940 KB Output is correct
42 Correct 15 ms 10836 KB Output is correct
43 Correct 14 ms 10888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 9896 KB Output is correct
2 Correct 5 ms 9712 KB Output is correct
3 Correct 5 ms 9684 KB Output is correct
4 Correct 5 ms 9684 KB Output is correct
5 Correct 5 ms 9716 KB Output is correct
6 Correct 7 ms 9684 KB Output is correct
7 Correct 7 ms 9684 KB Output is correct
8 Correct 6 ms 9684 KB Output is correct
9 Correct 6 ms 9684 KB Output is correct
10 Correct 5 ms 9684 KB Output is correct
11 Correct 748 ms 33212 KB Output is correct
12 Correct 5 ms 9684 KB Output is correct
13 Correct 775 ms 33180 KB Output is correct
14 Correct 5 ms 9684 KB Output is correct
15 Correct 775 ms 33176 KB Output is correct
16 Correct 769 ms 33180 KB Output is correct
17 Correct 800 ms 33172 KB Output is correct
18 Correct 742 ms 33228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9684 KB Output is correct
3 Correct 10 ms 10324 KB Output is correct
4 Correct 10 ms 10400 KB Output is correct
5 Correct 9 ms 10416 KB Output is correct
6 Correct 10 ms 10384 KB Output is correct
7 Correct 11 ms 10388 KB Output is correct
8 Correct 6 ms 9948 KB Output is correct
9 Correct 5 ms 9684 KB Output is correct
10 Correct 6 ms 9940 KB Output is correct
11 Correct 10 ms 10324 KB Output is correct
12 Correct 9 ms 10324 KB Output is correct
13 Correct 5 ms 9684 KB Output is correct
14 Correct 11 ms 10324 KB Output is correct
15 Correct 6 ms 9684 KB Output is correct
16 Correct 11 ms 10324 KB Output is correct
17 Correct 5 ms 9684 KB Output is correct
18 Correct 10 ms 10324 KB Output is correct
19 Correct 7 ms 9940 KB Output is correct
20 Correct 8 ms 10068 KB Output is correct
21 Correct 8 ms 10068 KB Output is correct
22 Correct 6 ms 9940 KB Output is correct
23 Correct 10 ms 10420 KB Output is correct
24 Correct 7 ms 9948 KB Output is correct
25 Correct 11 ms 10452 KB Output is correct
26 Correct 12 ms 10452 KB Output is correct
27 Correct 13 ms 10428 KB Output is correct
28 Correct 11 ms 10452 KB Output is correct
29 Correct 13 ms 10324 KB Output is correct
30 Correct 12 ms 10576 KB Output is correct
31 Correct 11 ms 10452 KB Output is correct
32 Correct 11 ms 10580 KB Output is correct
33 Correct 11 ms 10580 KB Output is correct
34 Correct 12 ms 10572 KB Output is correct
35 Correct 9 ms 10068 KB Output is correct
36 Correct 10 ms 10068 KB Output is correct
37 Correct 8 ms 10068 KB Output is correct
38 Correct 7 ms 9940 KB Output is correct
39 Correct 7 ms 9940 KB Output is correct
40 Correct 16 ms 10836 KB Output is correct
41 Correct 8 ms 9940 KB Output is correct
42 Correct 15 ms 10836 KB Output is correct
43 Correct 14 ms 10888 KB Output is correct
44 Correct 86 ms 11732 KB Output is correct
45 Correct 5 ms 9684 KB Output is correct
46 Correct 15 ms 10892 KB Output is correct
47 Correct 35 ms 11800 KB Output is correct
48 Correct 15 ms 10836 KB Output is correct
49 Correct 38 ms 11732 KB Output is correct
50 Correct 44 ms 11792 KB Output is correct
51 Correct 473 ms 13680 KB Output is correct
52 Correct 10 ms 10324 KB Output is correct
53 Correct 1053 ms 14148 KB Output is correct
54 Correct 1039 ms 14148 KB Output is correct
55 Correct 10 ms 10324 KB Output is correct
56 Correct 10 ms 10452 KB Output is correct
57 Correct 7 ms 9928 KB Output is correct
58 Correct 997 ms 14148 KB Output is correct
59 Correct 15 ms 10836 KB Output is correct
60 Correct 14 ms 10324 KB Output is correct
61 Correct 16 ms 10888 KB Output is correct
62 Correct 16 ms 10836 KB Output is correct
63 Correct 85 ms 11808 KB Output is correct
64 Correct 48 ms 11476 KB Output is correct
65 Correct 13 ms 10764 KB Output is correct
66 Correct 15 ms 10836 KB Output is correct
67 Correct 82 ms 12188 KB Output is correct
68 Correct 59 ms 11640 KB Output is correct
69 Correct 18 ms 10708 KB Output is correct
70 Correct 34 ms 11604 KB Output is correct
71 Correct 78 ms 12164 KB Output is correct
72 Correct 69 ms 12092 KB Output is correct
73 Correct 9 ms 10324 KB Output is correct
74 Correct 33 ms 11604 KB Output is correct
75 Correct 67 ms 12116 KB Output is correct
76 Correct 24 ms 11092 KB Output is correct
77 Correct 162 ms 12628 KB Output is correct
78 Correct 10 ms 10328 KB Output is correct
79 Correct 85 ms 11092 KB Output is correct
80 Correct 20 ms 11092 KB Output is correct
81 Correct 164 ms 12556 KB Output is correct
82 Correct 7 ms 9940 KB Output is correct
83 Correct 84 ms 11160 KB Output is correct
84 Correct 70 ms 12048 KB Output is correct
85 Correct 7 ms 9940 KB Output is correct
86 Correct 67 ms 12044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9684 KB Output is correct
3 Correct 10 ms 10324 KB Output is correct
4 Correct 10 ms 10400 KB Output is correct
5 Correct 9 ms 10416 KB Output is correct
6 Correct 10 ms 10384 KB Output is correct
7 Correct 11 ms 10388 KB Output is correct
8 Correct 6 ms 9948 KB Output is correct
9 Correct 5 ms 9684 KB Output is correct
10 Correct 6 ms 9940 KB Output is correct
11 Correct 10 ms 10324 KB Output is correct
12 Correct 9 ms 10324 KB Output is correct
13 Correct 5 ms 9684 KB Output is correct
14 Correct 11 ms 10324 KB Output is correct
15 Correct 6 ms 9684 KB Output is correct
16 Correct 11 ms 10324 KB Output is correct
17 Correct 5 ms 9684 KB Output is correct
18 Correct 10 ms 10324 KB Output is correct
19 Correct 7 ms 9940 KB Output is correct
20 Correct 8 ms 10068 KB Output is correct
21 Correct 8 ms 10068 KB Output is correct
22 Correct 6 ms 9940 KB Output is correct
23 Correct 10 ms 10420 KB Output is correct
24 Correct 7 ms 9948 KB Output is correct
25 Correct 11 ms 10452 KB Output is correct
26 Correct 12 ms 10452 KB Output is correct
27 Correct 13 ms 10428 KB Output is correct
28 Correct 11 ms 10452 KB Output is correct
29 Correct 13 ms 10324 KB Output is correct
30 Correct 12 ms 10576 KB Output is correct
31 Correct 11 ms 10452 KB Output is correct
32 Correct 11 ms 10580 KB Output is correct
33 Correct 11 ms 10580 KB Output is correct
34 Correct 12 ms 10572 KB Output is correct
35 Correct 9 ms 10068 KB Output is correct
36 Correct 10 ms 10068 KB Output is correct
37 Correct 8 ms 10068 KB Output is correct
38 Correct 7 ms 9940 KB Output is correct
39 Correct 7 ms 9940 KB Output is correct
40 Correct 16 ms 10836 KB Output is correct
41 Correct 8 ms 9940 KB Output is correct
42 Correct 15 ms 10836 KB Output is correct
43 Correct 14 ms 10888 KB Output is correct
44 Correct 5 ms 9656 KB Output is correct
45 Correct 266 ms 26104 KB Output is correct
46 Correct 97 ms 19056 KB Output is correct
47 Correct 315 ms 26188 KB Output is correct
48 Correct 277 ms 26188 KB Output is correct
49 Correct 57 ms 16716 KB Output is correct
50 Correct 267 ms 30732 KB Output is correct
51 Correct 282 ms 26172 KB Output is correct
52 Correct 58 ms 16716 KB Output is correct
53 Correct 59 ms 16672 KB Output is correct
54 Correct 21 ms 11988 KB Output is correct
55 Correct 284 ms 30740 KB Output is correct
56 Correct 39 ms 14292 KB Output is correct
57 Correct 57 ms 16676 KB Output is correct
58 Correct 84 ms 19088 KB Output is correct
59 Correct 36 ms 14396 KB Output is correct
60 Correct 37 ms 14284 KB Output is correct
61 Correct 81 ms 19088 KB Output is correct
62 Correct 59 ms 16680 KB Output is correct
63 Correct 125 ms 20264 KB Output is correct
64 Correct 34 ms 14408 KB Output is correct
65 Correct 185 ms 22628 KB Output is correct
66 Correct 60 ms 16740 KB Output is correct
67 Correct 135 ms 20172 KB Output is correct
68 Correct 166 ms 22012 KB Output is correct
69 Correct 179 ms 22616 KB Output is correct
70 Correct 62 ms 16716 KB Output is correct
71 Correct 226 ms 21996 KB Output is correct
72 Correct 120 ms 19868 KB Output is correct
73 Correct 213 ms 24108 KB Output is correct
74 Correct 63 ms 16724 KB Output is correct
75 Correct 65 ms 15448 KB Output is correct
76 Correct 123 ms 19860 KB Output is correct
77 Correct 224 ms 24060 KB Output is correct
78 Correct 97 ms 16912 KB Output is correct
79 Correct 59 ms 15380 KB Output is correct
80 Correct 29 ms 12500 KB Output is correct
81 Correct 100 ms 17008 KB Output is correct
82 Correct 154 ms 21452 KB Output is correct
83 Correct 33 ms 12588 KB Output is correct
84 Correct 152 ms 21440 KB Output is correct