Submission #934918

# Submission time Handle Problem Language Result Execution time Memory
934918 2024-02-28T07:36:02 Z irmuun Political Development (BOI17_politicaldevelopment) C++17
100 / 100
731 ms 336288 KB
#include<bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

ll n,k,d[50000];
vector<vector<bool>>dis(50000,vector<bool>(50000,0));
bool check(vector<ll>&v){
    for(ll i=0;i<v.size();i++){
        for(ll j=i+1;j<v.size();j++){
            if(dis[v[i]][v[j]]==false){
                return false;
            }
        }
    }
    return true;
}
 
int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n>>k;
    set<ll>adj[n];
    set<pair<ll,ll>>ord;
    for(ll i=0;i<n;i++){
        cin>>d[i];
        ord.insert({d[i],i});
        for(ll j=0;j<d[i];j++){
            ll u;
            cin>>u;
            adj[i].insert(u);
            dis[i][u]=true;
            dis[u][i]=true;
        }
    }
    ll ans=1;
    while(!ord.empty()){
        auto [s,i]=*ord.begin();
        ord.erase(ord.begin());
        ll sz=adj[i].size();
        ll p=(1ll<<sz);
        vector<ll>v;
        for(ll j=0;j<p;j++){
            ll r=0;
            for(auto x:adj[i]){
                if(j&(1ll<<r)){
                    v.pb(x);
                }
                r++;
            }
            if(check(v)){
                ans=max(ans,(ll)v.size()+1);
            }
            v.clear();
        }
        for(auto x:adj[i]){
            ll y=adj[x].size();
            adj[x].erase(i);
            ord.erase({y,x});
            ord.insert({y-1,x});
        }
        adj[i].clear();
    }
    cout<<ans;
}

Compilation message

politicaldevelopment.cpp: In function 'bool check(std::vector<long long int>&)':
politicaldevelopment.cpp:15:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(ll i=0;i<v.size();i++){
      |                ~^~~~~~~~~
politicaldevelopment.cpp:16:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |         for(ll j=i+1;j<v.size();j++){
      |                      ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 160 ms 309076 KB Output is correct
2 Correct 137 ms 309072 KB Output is correct
3 Correct 141 ms 310104 KB Output is correct
4 Correct 142 ms 310132 KB Output is correct
5 Correct 140 ms 310224 KB Output is correct
6 Correct 144 ms 310096 KB Output is correct
7 Correct 151 ms 310396 KB Output is correct
8 Correct 141 ms 309844 KB Output is correct
9 Correct 135 ms 309228 KB Output is correct
10 Correct 139 ms 309584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 160 ms 309076 KB Output is correct
2 Correct 137 ms 309072 KB Output is correct
3 Correct 141 ms 310104 KB Output is correct
4 Correct 142 ms 310132 KB Output is correct
5 Correct 140 ms 310224 KB Output is correct
6 Correct 144 ms 310096 KB Output is correct
7 Correct 151 ms 310396 KB Output is correct
8 Correct 141 ms 309844 KB Output is correct
9 Correct 135 ms 309228 KB Output is correct
10 Correct 139 ms 309584 KB Output is correct
11 Correct 155 ms 310116 KB Output is correct
12 Correct 145 ms 310152 KB Output is correct
13 Correct 135 ms 309228 KB Output is correct
14 Correct 146 ms 310220 KB Output is correct
15 Correct 141 ms 309072 KB Output is correct
16 Correct 141 ms 310168 KB Output is correct
17 Correct 146 ms 309072 KB Output is correct
18 Correct 140 ms 310096 KB Output is correct
19 Correct 147 ms 309600 KB Output is correct
20 Correct 134 ms 310004 KB Output is correct
21 Correct 142 ms 310096 KB Output is correct
22 Correct 137 ms 309588 KB Output is correct
23 Correct 151 ms 310356 KB Output is correct
24 Correct 137 ms 309840 KB Output is correct
25 Correct 137 ms 310404 KB Output is correct
26 Correct 143 ms 310348 KB Output is correct
27 Correct 141 ms 310096 KB Output is correct
28 Correct 155 ms 310388 KB Output is correct
29 Correct 149 ms 310176 KB Output is correct
30 Correct 143 ms 310356 KB Output is correct
31 Correct 153 ms 310352 KB Output is correct
32 Correct 142 ms 310356 KB Output is correct
33 Correct 146 ms 310356 KB Output is correct
34 Correct 148 ms 310352 KB Output is correct
35 Correct 142 ms 309756 KB Output is correct
36 Correct 139 ms 309844 KB Output is correct
37 Correct 140 ms 309680 KB Output is correct
38 Correct 139 ms 309552 KB Output is correct
39 Correct 148 ms 309360 KB Output is correct
40 Correct 151 ms 310604 KB Output is correct
41 Correct 140 ms 309588 KB Output is correct
42 Correct 145 ms 310548 KB Output is correct
43 Correct 148 ms 310748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 138 ms 309616 KB Output is correct
2 Correct 143 ms 309076 KB Output is correct
3 Correct 141 ms 309200 KB Output is correct
4 Correct 151 ms 309076 KB Output is correct
5 Correct 146 ms 309228 KB Output is correct
6 Correct 136 ms 309072 KB Output is correct
7 Correct 135 ms 309104 KB Output is correct
8 Correct 138 ms 309092 KB Output is correct
9 Correct 137 ms 309076 KB Output is correct
10 Correct 136 ms 309076 KB Output is correct
11 Correct 712 ms 335996 KB Output is correct
12 Correct 138 ms 309072 KB Output is correct
13 Correct 648 ms 336188 KB Output is correct
14 Correct 145 ms 309244 KB Output is correct
15 Correct 731 ms 336108 KB Output is correct
16 Correct 710 ms 336244 KB Output is correct
17 Correct 667 ms 336044 KB Output is correct
18 Correct 679 ms 336288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 160 ms 309076 KB Output is correct
2 Correct 137 ms 309072 KB Output is correct
3 Correct 141 ms 310104 KB Output is correct
4 Correct 142 ms 310132 KB Output is correct
5 Correct 140 ms 310224 KB Output is correct
6 Correct 144 ms 310096 KB Output is correct
7 Correct 151 ms 310396 KB Output is correct
8 Correct 141 ms 309844 KB Output is correct
9 Correct 135 ms 309228 KB Output is correct
10 Correct 139 ms 309584 KB Output is correct
11 Correct 155 ms 310116 KB Output is correct
12 Correct 145 ms 310152 KB Output is correct
13 Correct 135 ms 309228 KB Output is correct
14 Correct 146 ms 310220 KB Output is correct
15 Correct 141 ms 309072 KB Output is correct
16 Correct 141 ms 310168 KB Output is correct
17 Correct 146 ms 309072 KB Output is correct
18 Correct 140 ms 310096 KB Output is correct
19 Correct 147 ms 309600 KB Output is correct
20 Correct 134 ms 310004 KB Output is correct
21 Correct 142 ms 310096 KB Output is correct
22 Correct 137 ms 309588 KB Output is correct
23 Correct 151 ms 310356 KB Output is correct
24 Correct 137 ms 309840 KB Output is correct
25 Correct 137 ms 310404 KB Output is correct
26 Correct 143 ms 310348 KB Output is correct
27 Correct 141 ms 310096 KB Output is correct
28 Correct 155 ms 310388 KB Output is correct
29 Correct 149 ms 310176 KB Output is correct
30 Correct 143 ms 310356 KB Output is correct
31 Correct 153 ms 310352 KB Output is correct
32 Correct 142 ms 310356 KB Output is correct
33 Correct 146 ms 310356 KB Output is correct
34 Correct 148 ms 310352 KB Output is correct
35 Correct 142 ms 309756 KB Output is correct
36 Correct 139 ms 309844 KB Output is correct
37 Correct 140 ms 309680 KB Output is correct
38 Correct 139 ms 309552 KB Output is correct
39 Correct 148 ms 309360 KB Output is correct
40 Correct 151 ms 310604 KB Output is correct
41 Correct 140 ms 309588 KB Output is correct
42 Correct 145 ms 310548 KB Output is correct
43 Correct 148 ms 310748 KB Output is correct
44 Correct 171 ms 311644 KB Output is correct
45 Correct 140 ms 309132 KB Output is correct
46 Correct 147 ms 310612 KB Output is correct
47 Correct 155 ms 311480 KB Output is correct
48 Correct 142 ms 310608 KB Output is correct
49 Correct 156 ms 311636 KB Output is correct
50 Correct 159 ms 311636 KB Output is correct
51 Correct 253 ms 313536 KB Output is correct
52 Correct 146 ms 310088 KB Output is correct
53 Correct 305 ms 313940 KB Output is correct
54 Correct 357 ms 313940 KB Output is correct
55 Correct 157 ms 310092 KB Output is correct
56 Correct 145 ms 310168 KB Output is correct
57 Correct 140 ms 309812 KB Output is correct
58 Correct 294 ms 313876 KB Output is correct
59 Correct 145 ms 310768 KB Output is correct
60 Correct 141 ms 310100 KB Output is correct
61 Correct 146 ms 310688 KB Output is correct
62 Correct 143 ms 310600 KB Output is correct
63 Correct 177 ms 311652 KB Output is correct
64 Correct 160 ms 311476 KB Output is correct
65 Correct 166 ms 310644 KB Output is correct
66 Correct 164 ms 310692 KB Output is correct
67 Correct 173 ms 312292 KB Output is correct
68 Correct 169 ms 311248 KB Output is correct
69 Correct 145 ms 310556 KB Output is correct
70 Correct 156 ms 311380 KB Output is correct
71 Correct 167 ms 311896 KB Output is correct
72 Correct 166 ms 311816 KB Output is correct
73 Correct 142 ms 310096 KB Output is correct
74 Correct 165 ms 311484 KB Output is correct
75 Correct 168 ms 311924 KB Output is correct
76 Correct 151 ms 311076 KB Output is correct
77 Correct 189 ms 312516 KB Output is correct
78 Correct 141 ms 310100 KB Output is correct
79 Correct 161 ms 310788 KB Output is correct
80 Correct 155 ms 310984 KB Output is correct
81 Correct 196 ms 312360 KB Output is correct
82 Correct 139 ms 309500 KB Output is correct
83 Correct 162 ms 310648 KB Output is correct
84 Correct 176 ms 311840 KB Output is correct
85 Correct 143 ms 309504 KB Output is correct
86 Correct 165 ms 311796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 160 ms 309076 KB Output is correct
2 Correct 137 ms 309072 KB Output is correct
3 Correct 141 ms 310104 KB Output is correct
4 Correct 142 ms 310132 KB Output is correct
5 Correct 140 ms 310224 KB Output is correct
6 Correct 144 ms 310096 KB Output is correct
7 Correct 151 ms 310396 KB Output is correct
8 Correct 141 ms 309844 KB Output is correct
9 Correct 135 ms 309228 KB Output is correct
10 Correct 139 ms 309584 KB Output is correct
11 Correct 155 ms 310116 KB Output is correct
12 Correct 145 ms 310152 KB Output is correct
13 Correct 135 ms 309228 KB Output is correct
14 Correct 146 ms 310220 KB Output is correct
15 Correct 141 ms 309072 KB Output is correct
16 Correct 141 ms 310168 KB Output is correct
17 Correct 146 ms 309072 KB Output is correct
18 Correct 140 ms 310096 KB Output is correct
19 Correct 147 ms 309600 KB Output is correct
20 Correct 134 ms 310004 KB Output is correct
21 Correct 142 ms 310096 KB Output is correct
22 Correct 137 ms 309588 KB Output is correct
23 Correct 151 ms 310356 KB Output is correct
24 Correct 137 ms 309840 KB Output is correct
25 Correct 137 ms 310404 KB Output is correct
26 Correct 143 ms 310348 KB Output is correct
27 Correct 141 ms 310096 KB Output is correct
28 Correct 155 ms 310388 KB Output is correct
29 Correct 149 ms 310176 KB Output is correct
30 Correct 143 ms 310356 KB Output is correct
31 Correct 153 ms 310352 KB Output is correct
32 Correct 142 ms 310356 KB Output is correct
33 Correct 146 ms 310356 KB Output is correct
34 Correct 148 ms 310352 KB Output is correct
35 Correct 142 ms 309756 KB Output is correct
36 Correct 139 ms 309844 KB Output is correct
37 Correct 140 ms 309680 KB Output is correct
38 Correct 139 ms 309552 KB Output is correct
39 Correct 148 ms 309360 KB Output is correct
40 Correct 151 ms 310604 KB Output is correct
41 Correct 140 ms 309588 KB Output is correct
42 Correct 145 ms 310548 KB Output is correct
43 Correct 148 ms 310748 KB Output is correct
44 Correct 137 ms 309072 KB Output is correct
45 Correct 410 ms 329128 KB Output is correct
46 Correct 232 ms 322104 KB Output is correct
47 Correct 466 ms 329044 KB Output is correct
48 Correct 441 ms 328984 KB Output is correct
49 Correct 199 ms 319760 KB Output is correct
50 Correct 363 ms 333780 KB Output is correct
51 Correct 404 ms 329260 KB Output is correct
52 Correct 198 ms 319572 KB Output is correct
53 Correct 205 ms 319572 KB Output is correct
54 Correct 156 ms 315216 KB Output is correct
55 Correct 374 ms 333652 KB Output is correct
56 Correct 175 ms 317252 KB Output is correct
57 Correct 193 ms 319568 KB Output is correct
58 Correct 229 ms 322132 KB Output is correct
59 Correct 170 ms 317268 KB Output is correct
60 Correct 174 ms 317268 KB Output is correct
61 Correct 247 ms 321928 KB Output is correct
62 Correct 204 ms 319576 KB Output is correct
63 Correct 277 ms 323148 KB Output is correct
64 Correct 180 ms 317520 KB Output is correct
65 Correct 306 ms 325456 KB Output is correct
66 Correct 194 ms 319568 KB Output is correct
67 Correct 267 ms 323148 KB Output is correct
68 Correct 343 ms 325064 KB Output is correct
69 Correct 326 ms 325744 KB Output is correct
70 Correct 234 ms 319820 KB Output is correct
71 Correct 307 ms 324944 KB Output is correct
72 Correct 266 ms 322760 KB Output is correct
73 Correct 343 ms 326920 KB Output is correct
74 Correct 200 ms 319908 KB Output is correct
75 Correct 198 ms 316752 KB Output is correct
76 Correct 260 ms 322980 KB Output is correct
77 Correct 378 ms 327060 KB Output is correct
78 Correct 223 ms 318040 KB Output is correct
79 Correct 212 ms 316876 KB Output is correct
80 Correct 161 ms 312916 KB Output is correct
81 Correct 219 ms 318048 KB Output is correct
82 Correct 305 ms 324304 KB Output is correct
83 Correct 160 ms 312916 KB Output is correct
84 Correct 287 ms 324436 KB Output is correct