Submission #457999

#TimeUsernameProblemLanguageResultExecution timeMemory
457999julian33Political Development (BOI17_politicaldevelopment)C++14
77 / 100
3077 ms24176 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; struct custom_hash { static uint64_t splitmix64(uint64_t x) { // http://xorshift.di.unimi.it/splitmix64.c x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } }; unordered_set<int,custom_hash> graph[mxN]; vector<int> cur; int n,k; bool dfs(int s){ if(!s) return 1; int at=cur.back(); for(int i:graph[at]){ if(sz(graph[i])<s-1) continue; int bad=0; for(int &j:cur){ if(!graph[j].count(i)){ bad=1; break; } } if(bad) continue; cur.pb(i); if(dfs(s-1)) return 1; cur.pop_back(); } return 0; } bool check(int s){ for(int i=0;i<n;i++){ if(sz(graph[i])<s-1) continue; cur={i}; if(dfs(s-1)) return 1; } return 0; } 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; for(int i=0;i<n;i++){ int d; cin>>d; while(d--){ int x; cin>>x; graph[i].insert(x); } } for(int i=0;i<n;i++){ vector<int> rem; for(int j:graph[i]){ if(!graph[j].count(i) || j<=i) rem.pb(j); } for(int &j:rem) graph[i].erase(j); } int l=1; int r=k; int ans=1; while(l<=r){ int mid=(l+r)>>1; if(check(mid)){ ans=mid; l=mid+1; } else{ r=mid-1; } } 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...