Submission #458011

#TimeUsernameProblemLanguageResultExecution timeMemory
458011julian33Political Development (BOI17_politicaldevelopment)C++14
62 / 100
3100 ms26344 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #define deb(...) logger(#__VA_ARGS__, __VA_ARGS__) template<typename ...Args> void logger(string vars, Args&&... values) { cerr<<vars<<" = "; string delim=""; (...,(cerr<<delim<<values,delim=", ")); cerr<<"\n"; } #else #define deb(...) logger(#__VA_ARGS__, __VA_ARGS__) template<typename ...Args> void logger(string vars, Args&&... values) {} #endif #define pb push_back #define sz(x) (int)(x.size()) typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; template<typename T> inline void maxa(T& a,T b){a=max(a,b);} template<typename T> inline void mina(T& a,T b){a=min(a,b);} mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int mxN=5e4+5; //make sure this is right const int mod=1e9+7; int n,k,deg[mxN],seen[mxN]; set<int> graph[mxN]; int main(){ cin.sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef LOCAL freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif cin>>n>>k; priority_queue<pii,vector<pii>,greater<pii>> q; for(int i=0;i<n;i++){ cin>>deg[i]; for(int j=0;j<deg[i];j++){ int x; cin>>x; graph[i].insert(x); } q.push({deg[i],i}); } int ans=1; while(sz(q)){ pii cur=q.top(); q.pop(); if(cur.first!=deg[cur.second]) continue; int at=cur.second; seen[at]=1; vector<int> nd={at}; for(int i:graph[at]){ if(!seen[i]){ deg[i]--; q.push({deg[i],i}); nd.pb(i); } } for(int mask=0;mask<(1<<sz(nd));mask++){ int yes=1; for(int i=0;i<sz(nd);i++){ if(!(mask&(1<<i))) continue; for(int j=0;j<sz(nd);j++){ if(!(mask&(1<<j))) continue; if(i==j) continue; yes&=(graph[nd[i]].count(nd[j])); yes&=(graph[nd[j]].count(nd[i])); } } if(yes) maxa(ans,__builtin_popcount(mask)); } } cout<<ans<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...