Submission #721161

# Submission time Handle Problem Language Result Execution time Memory
721161 2023-04-10T11:51:57 Z ktkerem Political Development (BOI17_politicaldevelopment) C++17
100 / 100
675 ms 57060 KB
/*#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/
#include<bits/stdc++.h>
typedef int ll;
typedef long double ld;
typedef __int128 vll;
typedef long long ftyp;
typedef std::complex<ftyp> vec;
#define llll std::pair<ll , ll>
#define pb push_back
#define fi first
#define sec second
#define cx real
#define cy imag
#define all(a) a.begin() , a.end()
#define debug std::cout << "!!ALERT ALERT!!" << std::endl;  
const ll limit = 1e9+7;
const ll sus = 5e4+5;
std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
ll n , k;
std::vector<ll> adj[sus] , v[sus];
std::map<ll , ll> mp[sus];
std::set<llll> st;
ll dlt[sus] , dd[sus] , ist[4080];
void solve(){
  std::cin >> n >> k;
  for(ll i = 0 ; n>i;i++){
    ll d;std::cin >> d;
    dd[i] = d;
    for(ll j = 0;d>j;j++){
      ll x;std::cin >> x;
      adj[i].pb(x);
      v[x].pb(i);
      mp[i][x] = 1;
    }
    st.insert({dd[i] , i});
  }
  ll ans = 1;
  while(!st.empty()){
    llll a = *st.begin();
    st.erase(st.begin());
    std::vector<ll> vv;
    dlt[a.sec] = 1;
    for(auto j:adj[a.sec]){
      if(dlt[j] == 0){
        vv.pb(j);
      }
    }
    ll o = vv.size();
    memset(ist , 0 , sizeof(ist));
    ist[0] = 1;
    for(auto j:v[a.sec]){
      if(dlt[j] == 1){
        continue;
      }
      st.erase(st.find({dd[j] , j}));
      dd[j]--;
      st.insert({dd[j] , j});
    }
    if(o > 12){
      while(1){
        debug;
      }
    }
    for(ll i = 1;(1ll << o) > i;i++){
      ll ff = (1ll << std::__lg(i)) ^ i;
      //std::cout << i << " " << ff << " " << vv[std::__lg(i)] << " " << a.sec << "\n";
      if(ist[ff] == 0 || mp[vv[std::__lg(i)]][a.sec] == 0){
        continue;
      }
      ll kd = 1;
      for(ll j = 0;o>j;j++){
        if(((ff & (1ll << j)) && (mp[vv[j]][vv[std::__lg(i)]] == 0 || mp[vv[std::__lg(i)]][vv[j]] == 0)) && (vv[std::__lg(i)] != vv[j])){
          kd = 0;
          break;
        }
      }
      ist[i] = kd;
      if(kd){
        ans = std::max(ans , __builtin_popcount(i) + 1);
      }
    }
  }
  std::cout << ans << "\n";
  return;/**/
}
int main(){
  std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);
  ll t = 1;
  //std::cin >> t;
  while(t--){
    solve();
  }
}

Compilation message

politicaldevelopment.cpp:5:78: warning: "/*" within comment [-Wcomment]
    5 | #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/
      |
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 11 ms 6164 KB Output is correct
4 Correct 10 ms 6100 KB Output is correct
5 Correct 11 ms 6192 KB Output is correct
6 Correct 11 ms 6192 KB Output is correct
7 Correct 10 ms 6232 KB Output is correct
8 Correct 6 ms 5288 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 6 ms 5332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 11 ms 6164 KB Output is correct
4 Correct 10 ms 6100 KB Output is correct
5 Correct 11 ms 6192 KB Output is correct
6 Correct 11 ms 6192 KB Output is correct
7 Correct 10 ms 6232 KB Output is correct
8 Correct 6 ms 5288 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 6 ms 5332 KB Output is correct
11 Correct 11 ms 6100 KB Output is correct
12 Correct 10 ms 6192 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 10 ms 6192 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 10 ms 6196 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 10 ms 6228 KB Output is correct
19 Correct 5 ms 5332 KB Output is correct
20 Correct 10 ms 5892 KB Output is correct
21 Correct 7 ms 5844 KB Output is correct
22 Correct 6 ms 5332 KB Output is correct
23 Correct 15 ms 6228 KB Output is correct
24 Correct 6 ms 5332 KB Output is correct
25 Correct 14 ms 6184 KB Output is correct
26 Correct 11 ms 6228 KB Output is correct
27 Correct 10 ms 6100 KB Output is correct
28 Correct 12 ms 6196 KB Output is correct
29 Correct 10 ms 6164 KB Output is correct
30 Correct 15 ms 6264 KB Output is correct
31 Correct 12 ms 6288 KB Output is correct
32 Correct 13 ms 6324 KB Output is correct
33 Correct 13 ms 6312 KB Output is correct
34 Correct 13 ms 6228 KB Output is correct
35 Correct 8 ms 5588 KB Output is correct
36 Correct 10 ms 5588 KB Output is correct
37 Correct 7 ms 5588 KB Output is correct
38 Correct 6 ms 5460 KB Output is correct
39 Correct 7 ms 5460 KB Output is correct
40 Correct 17 ms 6740 KB Output is correct
41 Correct 6 ms 5364 KB Output is correct
42 Correct 16 ms 6612 KB Output is correct
43 Correct 16 ms 6740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 5292 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 5028 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 648 ms 56988 KB Output is correct
12 Correct 3 ms 5024 KB Output is correct
13 Correct 673 ms 56976 KB Output is correct
14 Correct 3 ms 4948 KB Output is correct
15 Correct 632 ms 57060 KB Output is correct
16 Correct 633 ms 56984 KB Output is correct
17 Correct 660 ms 56992 KB Output is correct
18 Correct 675 ms 56904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 11 ms 6164 KB Output is correct
4 Correct 10 ms 6100 KB Output is correct
5 Correct 11 ms 6192 KB Output is correct
6 Correct 11 ms 6192 KB Output is correct
7 Correct 10 ms 6232 KB Output is correct
8 Correct 6 ms 5288 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 6 ms 5332 KB Output is correct
11 Correct 11 ms 6100 KB Output is correct
12 Correct 10 ms 6192 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 10 ms 6192 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 10 ms 6196 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 10 ms 6228 KB Output is correct
19 Correct 5 ms 5332 KB Output is correct
20 Correct 10 ms 5892 KB Output is correct
21 Correct 7 ms 5844 KB Output is correct
22 Correct 6 ms 5332 KB Output is correct
23 Correct 15 ms 6228 KB Output is correct
24 Correct 6 ms 5332 KB Output is correct
25 Correct 14 ms 6184 KB Output is correct
26 Correct 11 ms 6228 KB Output is correct
27 Correct 10 ms 6100 KB Output is correct
28 Correct 12 ms 6196 KB Output is correct
29 Correct 10 ms 6164 KB Output is correct
30 Correct 15 ms 6264 KB Output is correct
31 Correct 12 ms 6288 KB Output is correct
32 Correct 13 ms 6324 KB Output is correct
33 Correct 13 ms 6312 KB Output is correct
34 Correct 13 ms 6228 KB Output is correct
35 Correct 8 ms 5588 KB Output is correct
36 Correct 10 ms 5588 KB Output is correct
37 Correct 7 ms 5588 KB Output is correct
38 Correct 6 ms 5460 KB Output is correct
39 Correct 7 ms 5460 KB Output is correct
40 Correct 17 ms 6740 KB Output is correct
41 Correct 6 ms 5364 KB Output is correct
42 Correct 16 ms 6612 KB Output is correct
43 Correct 16 ms 6740 KB Output is correct
44 Correct 47 ms 7856 KB Output is correct
45 Correct 3 ms 4948 KB Output is correct
46 Correct 18 ms 6752 KB Output is correct
47 Correct 32 ms 9124 KB Output is correct
48 Correct 16 ms 6732 KB Output is correct
49 Correct 33 ms 9156 KB Output is correct
50 Correct 39 ms 9148 KB Output is correct
51 Correct 95 ms 16716 KB Output is correct
52 Correct 10 ms 6100 KB Output is correct
53 Correct 66 ms 11300 KB Output is correct
54 Correct 143 ms 19032 KB Output is correct
55 Correct 11 ms 6220 KB Output is correct
56 Correct 10 ms 6100 KB Output is correct
57 Correct 6 ms 5332 KB Output is correct
58 Correct 69 ms 11340 KB Output is correct
59 Correct 14 ms 6680 KB Output is correct
60 Correct 11 ms 6188 KB Output is correct
61 Correct 15 ms 6672 KB Output is correct
62 Correct 14 ms 6660 KB Output is correct
63 Correct 45 ms 7980 KB Output is correct
64 Correct 35 ms 7636 KB Output is correct
65 Correct 17 ms 6484 KB Output is correct
66 Correct 15 ms 6572 KB Output is correct
67 Correct 51 ms 10196 KB Output is correct
68 Correct 34 ms 7704 KB Output is correct
69 Correct 15 ms 6592 KB Output is correct
70 Correct 31 ms 8452 KB Output is correct
71 Correct 61 ms 10148 KB Output is correct
72 Correct 47 ms 9892 KB Output is correct
73 Correct 10 ms 6160 KB Output is correct
74 Correct 30 ms 8652 KB Output is correct
75 Correct 41 ms 10060 KB Output is correct
76 Correct 23 ms 7380 KB Output is correct
77 Correct 77 ms 12416 KB Output is correct
78 Correct 13 ms 6100 KB Output is correct
79 Correct 28 ms 8732 KB Output is correct
80 Correct 23 ms 7392 KB Output is correct
81 Correct 67 ms 12452 KB Output is correct
82 Correct 7 ms 5468 KB Output is correct
83 Correct 29 ms 8736 KB Output is correct
84 Correct 47 ms 10316 KB Output is correct
85 Correct 6 ms 5420 KB Output is correct
86 Correct 39 ms 10348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 11 ms 6164 KB Output is correct
4 Correct 10 ms 6100 KB Output is correct
5 Correct 11 ms 6192 KB Output is correct
6 Correct 11 ms 6192 KB Output is correct
7 Correct 10 ms 6232 KB Output is correct
8 Correct 6 ms 5288 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 6 ms 5332 KB Output is correct
11 Correct 11 ms 6100 KB Output is correct
12 Correct 10 ms 6192 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 10 ms 6192 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 10 ms 6196 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 10 ms 6228 KB Output is correct
19 Correct 5 ms 5332 KB Output is correct
20 Correct 10 ms 5892 KB Output is correct
21 Correct 7 ms 5844 KB Output is correct
22 Correct 6 ms 5332 KB Output is correct
23 Correct 15 ms 6228 KB Output is correct
24 Correct 6 ms 5332 KB Output is correct
25 Correct 14 ms 6184 KB Output is correct
26 Correct 11 ms 6228 KB Output is correct
27 Correct 10 ms 6100 KB Output is correct
28 Correct 12 ms 6196 KB Output is correct
29 Correct 10 ms 6164 KB Output is correct
30 Correct 15 ms 6264 KB Output is correct
31 Correct 12 ms 6288 KB Output is correct
32 Correct 13 ms 6324 KB Output is correct
33 Correct 13 ms 6312 KB Output is correct
34 Correct 13 ms 6228 KB Output is correct
35 Correct 8 ms 5588 KB Output is correct
36 Correct 10 ms 5588 KB Output is correct
37 Correct 7 ms 5588 KB Output is correct
38 Correct 6 ms 5460 KB Output is correct
39 Correct 7 ms 5460 KB Output is correct
40 Correct 17 ms 6740 KB Output is correct
41 Correct 6 ms 5364 KB Output is correct
42 Correct 16 ms 6612 KB Output is correct
43 Correct 16 ms 6740 KB Output is correct
44 Correct 3 ms 5028 KB Output is correct
45 Correct 395 ms 33188 KB Output is correct
46 Correct 158 ms 19024 KB Output is correct
47 Correct 403 ms 33544 KB Output is correct
48 Correct 400 ms 33144 KB Output is correct
49 Correct 92 ms 16624 KB Output is correct
50 Correct 294 ms 33724 KB Output is correct
51 Correct 399 ms 33460 KB Output is correct
52 Correct 101 ms 16664 KB Output is correct
53 Correct 101 ms 16668 KB Output is correct
54 Correct 39 ms 7828 KB Output is correct
55 Correct 288 ms 33584 KB Output is correct
56 Correct 74 ms 13596 KB Output is correct
57 Correct 110 ms 16712 KB Output is correct
58 Correct 131 ms 18772 KB Output is correct
59 Correct 66 ms 13624 KB Output is correct
60 Correct 73 ms 13620 KB Output is correct
61 Correct 131 ms 18852 KB Output is correct
62 Correct 104 ms 16204 KB Output is correct
63 Correct 189 ms 20620 KB Output is correct
64 Correct 67 ms 13528 KB Output is correct
65 Correct 301 ms 24840 KB Output is correct
66 Correct 109 ms 16216 KB Output is correct
67 Correct 203 ms 20612 KB Output is correct
68 Correct 250 ms 23584 KB Output is correct
69 Correct 253 ms 24772 KB Output is correct
70 Correct 130 ms 16308 KB Output is correct
71 Correct 262 ms 23724 KB Output is correct
72 Correct 206 ms 20160 KB Output is correct
73 Correct 339 ms 28852 KB Output is correct
74 Correct 110 ms 16252 KB Output is correct
75 Correct 111 ms 13604 KB Output is correct
76 Correct 210 ms 20112 KB Output is correct
77 Correct 294 ms 28932 KB Output is correct
78 Correct 133 ms 16896 KB Output is correct
79 Correct 123 ms 13392 KB Output is correct
80 Correct 36 ms 9196 KB Output is correct
81 Correct 149 ms 16824 KB Output is correct
82 Correct 228 ms 22300 KB Output is correct
83 Correct 44 ms 9384 KB Output is correct
84 Correct 233 ms 22344 KB Output is correct