Submission #589343

# Submission time Handle Problem Language Result Execution time Memory
589343 2022-07-04T13:35:12 Z MohammadAghil Political Development (BOI17_politicaldevelopment) C++17
0 / 100
3 ms 1748 KB
      #include <bits/stdc++.h>
//   #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("avx2")
    using namespace std;
  typedef long long ll;
   typedef pair<ll, int> pp;
    #define er(args ...) cerr << __LINE__ << ": ", err(new istringstream(string(#args)), args), cerr << endl
      #define per(i,r,l) for(int i = (r); i >= (l); i--)
        #define rep(i,l,r) for(int i = (l); i < (r); i++)
           #define all(x) begin(x), end(x)
              #define sz(x) (int)(x).size()
                  #define pb push_back
                      #define ss second
                           #define ff first
                                   void err(istringstream *iss){}template<typename T,typename ...Args> void err(istringstream *iss,const T &_val, const Args&...args){string _name;*iss>>_name;if(_name.back()==',')_name.pop_back();cerr<<_name<<" = "<<_val<<", ",err(iss,args...);}
void IOS(){
     cin.tie(0) -> sync_with_stdio(0);
     // #ifndef ONLINE_JUDGE
     //      freopen("in.in", "r", stdin);
     //      freopen("out.out", "w", stdout);
     // #endif
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod = 998244353, maxn = 5e4 + 5, maxk = 11, lg = 35, inf = ll(1e18) + 5;
ll pw(ll a,ll b,ll md=mod){if(!b)return 1;ll k=pw(a,b>>1ll);return k*k%md*(b&1ll?a:1)%md;}

vector<int> adj[maxn];
vector<int> mask[maxk][maxk];
int cnt[maxn];

bool chk(int x, vector<int> cand){
     int n = sz(cand);
     vector<int> adj(n);
     rep(i,0,n) {
          adj[i] ^= 1<<i;
          rep(j,0,i){
               auto it = lower_bound(all(::adj[i]), j);
               if(it != end(::adj[i]) && *it == j) adj[i] ^= 1<<j, adj[j] ^= 1<<i;
          }
     }
     for(int m: mask[n][x]){
          bool ok = true;
          rep(i,0,n) if((m>>i&1) && (adj[i]&m) != m) {
               ok = false;
               break;
          } 
          if(ok) return true;
     }
     return false;
}

int main(){ IOS();
     int n, k, ans = 1; cin >> n >> k;
     set<pp> s;
     rep(i,0,n){
          int d; cin >> d;
          s.insert({cnt[i] = d, i});
          adj[i].resize(d);
          rep(j,0,d) cin >> adj[i][j];
          sort(all(adj[i]));
     }
     rep(i,0,k+1){
          rep(j,0,1<<i) mask[i][__builtin_popcount(j)].pb(j);
     }
     while(sz(s)){
          int r = s.begin()->ff;
          s.erase(begin(s)), cnt[r] = -1;
          vector<int> ad;
          for(int c: adj[r]) if(cnt[c] > 0){
               ad.pb(c);
               s.erase(pp(cnt[c], c));
               s.insert({--cnt[c], c});
          }
          while(ans < sz(ad) && chk(ans+1, ad)) ans++;
     }
     cout << ans << '\n';
     return 0;  
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1748 KB Output is correct
2 Incorrect 1 ms 1504 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1492 KB Output isn't correct
2 Halted 0 ms 0 KB -