Submission #550440

# Submission time Handle Problem Language Result Execution time Memory
550440 2022-04-18T08:13:19 Z Jarif_Rahman Political Development (BOI17_politicaldevelopment) C++17
100 / 100
865 ms 28380 KB
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;

int n, k;
int ans = 0;
vector<unordered_set<int>> v;
vector<int> nodes;
vector<int> ss;
set<pair<int,int>> deg;

void bf(int in){
    if(in == nodes.size()){
        bool ok = 1;
        for(int i = 0; i < ss.size(); i++) for(int j = i+1; j < ss.size(); j++)
            if(v[ss[i]].find(ss[j]) == v[ss[i]].end()) ok = 0;
        if(ok) ans = max(ans, int(ss.size()));
        return;
    }
    ss.pb(nodes[in]);
    bf(in+1);
    ss.pop_back();
    bf(in+1);
}

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

    cin >> n >> k;
    v.resize(n);

    for(int i = 0; i < n; i++){
        int d; cin >> d;
        while(d--){
            int x; cin >> x;
            v[i].insert(x);
        }
    }

    for(int i = 0; i < n; i++) deg.insert({v[i].size(), i});

    while(!deg.empty()){
        auto [s, i] = *deg.begin();
        deg.erase(deg.begin());
        nodes.pb(i);
        for(int x: v[i]) nodes.pb(x);
        bf(0);
        nodes.clear();
        for(int x: v[i]){
            deg.erase(make_pair(int(v[x].size()), x));
            v[x].erase(i);
            deg.insert(make_pair(int(v[x].size()), x));
        }
    }

    cout << ans << "\n";
}

Compilation message

politicaldevelopment.cpp: In function 'void bf(int)':
politicaldevelopment.cpp:17:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     if(in == nodes.size()){
      |        ~~~^~~~~~~~~~~~~~~
politicaldevelopment.cpp:19:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         for(int i = 0; i < ss.size(); i++) for(int j = i+1; j < ss.size(); j++)
      |                        ~~^~~~~~~~~~~
politicaldevelopment.cpp:19:63: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         for(int i = 0; i < ss.size(); i++) for(int j = i+1; j < ss.size(); j++)
      |                                                             ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 7 ms 1748 KB Output is correct
4 Correct 5 ms 1720 KB Output is correct
5 Correct 7 ms 1768 KB Output is correct
6 Correct 7 ms 1748 KB Output is correct
7 Correct 6 ms 1748 KB Output is correct
8 Correct 2 ms 852 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 3 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 7 ms 1748 KB Output is correct
4 Correct 5 ms 1720 KB Output is correct
5 Correct 7 ms 1768 KB Output is correct
6 Correct 7 ms 1748 KB Output is correct
7 Correct 6 ms 1748 KB Output is correct
8 Correct 2 ms 852 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 3 ms 852 KB Output is correct
11 Correct 5 ms 1748 KB Output is correct
12 Correct 5 ms 1748 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 5 ms 1736 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 7 ms 1744 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 7 ms 1748 KB Output is correct
19 Correct 2 ms 836 KB Output is correct
20 Correct 4 ms 1492 KB Output is correct
21 Correct 4 ms 1488 KB Output is correct
22 Correct 2 ms 724 KB Output is correct
23 Correct 9 ms 1748 KB Output is correct
24 Correct 3 ms 852 KB Output is correct
25 Correct 8 ms 1824 KB Output is correct
26 Correct 9 ms 1748 KB Output is correct
27 Correct 5 ms 1692 KB Output is correct
28 Correct 9 ms 1748 KB Output is correct
29 Correct 7 ms 1748 KB Output is correct
30 Correct 7 ms 1876 KB Output is correct
31 Correct 10 ms 1776 KB Output is correct
32 Correct 9 ms 1876 KB Output is correct
33 Correct 9 ms 1876 KB Output is correct
34 Correct 8 ms 1876 KB Output is correct
35 Correct 4 ms 1108 KB Output is correct
36 Correct 4 ms 980 KB Output is correct
37 Correct 4 ms 980 KB Output is correct
38 Correct 3 ms 712 KB Output is correct
39 Correct 3 ms 724 KB Output is correct
40 Correct 13 ms 2132 KB Output is correct
41 Correct 3 ms 720 KB Output is correct
42 Correct 15 ms 2004 KB Output is correct
43 Correct 16 ms 2116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 852 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 695 ms 27552 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 700 ms 27528 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 715 ms 27536 KB Output is correct
16 Correct 690 ms 27500 KB Output is correct
17 Correct 685 ms 27532 KB Output is correct
18 Correct 708 ms 27592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 7 ms 1748 KB Output is correct
4 Correct 5 ms 1720 KB Output is correct
5 Correct 7 ms 1768 KB Output is correct
6 Correct 7 ms 1748 KB Output is correct
7 Correct 6 ms 1748 KB Output is correct
8 Correct 2 ms 852 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 3 ms 852 KB Output is correct
11 Correct 5 ms 1748 KB Output is correct
12 Correct 5 ms 1748 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 5 ms 1736 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 7 ms 1744 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 7 ms 1748 KB Output is correct
19 Correct 2 ms 836 KB Output is correct
20 Correct 4 ms 1492 KB Output is correct
21 Correct 4 ms 1488 KB Output is correct
22 Correct 2 ms 724 KB Output is correct
23 Correct 9 ms 1748 KB Output is correct
24 Correct 3 ms 852 KB Output is correct
25 Correct 8 ms 1824 KB Output is correct
26 Correct 9 ms 1748 KB Output is correct
27 Correct 5 ms 1692 KB Output is correct
28 Correct 9 ms 1748 KB Output is correct
29 Correct 7 ms 1748 KB Output is correct
30 Correct 7 ms 1876 KB Output is correct
31 Correct 10 ms 1776 KB Output is correct
32 Correct 9 ms 1876 KB Output is correct
33 Correct 9 ms 1876 KB Output is correct
34 Correct 8 ms 1876 KB Output is correct
35 Correct 4 ms 1108 KB Output is correct
36 Correct 4 ms 980 KB Output is correct
37 Correct 4 ms 980 KB Output is correct
38 Correct 3 ms 712 KB Output is correct
39 Correct 3 ms 724 KB Output is correct
40 Correct 13 ms 2132 KB Output is correct
41 Correct 3 ms 720 KB Output is correct
42 Correct 15 ms 2004 KB Output is correct
43 Correct 16 ms 2116 KB Output is correct
44 Correct 59 ms 2772 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 11 ms 1996 KB Output is correct
47 Correct 24 ms 2888 KB Output is correct
48 Correct 13 ms 1996 KB Output is correct
49 Correct 25 ms 2900 KB Output is correct
50 Correct 26 ms 2772 KB Output is correct
51 Correct 418 ms 4552 KB Output is correct
52 Correct 5 ms 1744 KB Output is correct
53 Correct 425 ms 4932 KB Output is correct
54 Correct 865 ms 5076 KB Output is correct
55 Correct 7 ms 1748 KB Output is correct
56 Correct 8 ms 1740 KB Output is correct
57 Correct 2 ms 852 KB Output is correct
58 Correct 423 ms 4940 KB Output is correct
59 Correct 10 ms 2112 KB Output is correct
60 Correct 9 ms 1748 KB Output is correct
61 Correct 13 ms 2028 KB Output is correct
62 Correct 13 ms 2004 KB Output is correct
63 Correct 62 ms 2772 KB Output is correct
64 Correct 32 ms 2644 KB Output is correct
65 Correct 9 ms 2004 KB Output is correct
66 Correct 12 ms 2032 KB Output is correct
67 Correct 67 ms 3200 KB Output is correct
68 Correct 42 ms 2636 KB Output is correct
69 Correct 12 ms 1996 KB Output is correct
70 Correct 25 ms 2644 KB Output is correct
71 Correct 66 ms 3128 KB Output is correct
72 Correct 51 ms 3096 KB Output is correct
73 Correct 8 ms 1748 KB Output is correct
74 Correct 23 ms 2644 KB Output is correct
75 Correct 49 ms 3160 KB Output is correct
76 Correct 15 ms 2388 KB Output is correct
77 Correct 152 ms 3540 KB Output is correct
78 Correct 6 ms 1740 KB Output is correct
79 Correct 74 ms 1876 KB Output is correct
80 Correct 16 ms 2388 KB Output is correct
81 Correct 139 ms 3484 KB Output is correct
82 Correct 3 ms 724 KB Output is correct
83 Correct 76 ms 1940 KB Output is correct
84 Correct 57 ms 2900 KB Output is correct
85 Correct 3 ms 716 KB Output is correct
86 Correct 70 ms 2968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 7 ms 1748 KB Output is correct
4 Correct 5 ms 1720 KB Output is correct
5 Correct 7 ms 1768 KB Output is correct
6 Correct 7 ms 1748 KB Output is correct
7 Correct 6 ms 1748 KB Output is correct
8 Correct 2 ms 852 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 3 ms 852 KB Output is correct
11 Correct 5 ms 1748 KB Output is correct
12 Correct 5 ms 1748 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 5 ms 1736 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 7 ms 1744 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 7 ms 1748 KB Output is correct
19 Correct 2 ms 836 KB Output is correct
20 Correct 4 ms 1492 KB Output is correct
21 Correct 4 ms 1488 KB Output is correct
22 Correct 2 ms 724 KB Output is correct
23 Correct 9 ms 1748 KB Output is correct
24 Correct 3 ms 852 KB Output is correct
25 Correct 8 ms 1824 KB Output is correct
26 Correct 9 ms 1748 KB Output is correct
27 Correct 5 ms 1692 KB Output is correct
28 Correct 9 ms 1748 KB Output is correct
29 Correct 7 ms 1748 KB Output is correct
30 Correct 7 ms 1876 KB Output is correct
31 Correct 10 ms 1776 KB Output is correct
32 Correct 9 ms 1876 KB Output is correct
33 Correct 9 ms 1876 KB Output is correct
34 Correct 8 ms 1876 KB Output is correct
35 Correct 4 ms 1108 KB Output is correct
36 Correct 4 ms 980 KB Output is correct
37 Correct 4 ms 980 KB Output is correct
38 Correct 3 ms 712 KB Output is correct
39 Correct 3 ms 724 KB Output is correct
40 Correct 13 ms 2132 KB Output is correct
41 Correct 3 ms 720 KB Output is correct
42 Correct 15 ms 2004 KB Output is correct
43 Correct 16 ms 2116 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 216 ms 22248 KB Output is correct
46 Correct 104 ms 16808 KB Output is correct
47 Correct 270 ms 22368 KB Output is correct
48 Correct 218 ms 22332 KB Output is correct
49 Correct 72 ms 15244 KB Output is correct
50 Correct 255 ms 28380 KB Output is correct
51 Correct 218 ms 22252 KB Output is correct
52 Correct 66 ms 15036 KB Output is correct
53 Correct 67 ms 15248 KB Output is correct
54 Correct 16 ms 5460 KB Output is correct
55 Correct 246 ms 28376 KB Output is correct
56 Correct 59 ms 12700 KB Output is correct
57 Correct 64 ms 15068 KB Output is correct
58 Correct 95 ms 16412 KB Output is correct
59 Correct 50 ms 12756 KB Output is correct
60 Correct 60 ms 12812 KB Output is correct
61 Correct 102 ms 16440 KB Output is correct
62 Correct 60 ms 14572 KB Output is correct
63 Correct 129 ms 17340 KB Output is correct
64 Correct 46 ms 12732 KB Output is correct
65 Correct 191 ms 19196 KB Output is correct
66 Correct 65 ms 14588 KB Output is correct
67 Correct 130 ms 17356 KB Output is correct
68 Correct 176 ms 18756 KB Output is correct
69 Correct 190 ms 19276 KB Output is correct
70 Correct 77 ms 14660 KB Output is correct
71 Correct 158 ms 18752 KB Output is correct
72 Correct 128 ms 17432 KB Output is correct
73 Correct 176 ms 20452 KB Output is correct
74 Correct 83 ms 14668 KB Output is correct
75 Correct 83 ms 9156 KB Output is correct
76 Correct 118 ms 17368 KB Output is correct
77 Correct 191 ms 20380 KB Output is correct
78 Correct 112 ms 10236 KB Output is correct
79 Correct 86 ms 9128 KB Output is correct
80 Correct 33 ms 4856 KB Output is correct
81 Correct 95 ms 10288 KB Output is correct
82 Correct 165 ms 18312 KB Output is correct
83 Correct 31 ms 4892 KB Output is correct
84 Correct 199 ms 18284 KB Output is correct