Submission #162680

#TimeUsernameProblemLanguageResultExecution timeMemory
162680MvCFriends (BOI17_friends)C++11
20 / 100
1069 ms3192 KiB
#pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #include <bits/stdc++.h> #define rc(x) return cout<<x<<endl,0 #define pb push_back #define mkp make_pair #define in insert #define er erase #define fd find #define fr first #define sc second typedef long long ll; typedef long double ld; const ll INF=0x3f3f3f3f3f3f3f3f; const ll llinf=(1LL<<62); const int inf=(1<<30); const int nmax=1e5+50; const int mod=1e9+7; using namespace std; int n,p,q,x,a[20],b[20],i,j,t,tot,y; vector<int>f[(1<<16)+5]; int main() { //freopen("sol.in","r",stdin); //freopen("sol.out","w",stdout); //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0); cin>>n>>p>>q; for(i=0;i<n;i++) { cin>>y; while(y--) { cin>>x; a[i]|=(1<<x); b[x]|=(1<<i); } } for(i=0;i<n;i++) { if(a[i]!=b[i])rc("detention"); } for(i=0;i<(1<<n);i++) { if(__builtin_popcount(i)>p)continue; tot=0; for(j=0;j<n;j++) { if(!(i&(1<<j)))continue; x=__builtin_popcount(a[j])-__builtin_popcount(a[j]&i); tot+=x; } if(tot<=q)f[i].pb(i); } for(i=0;i<(1<<n);i++) { if(!f[i].empty())continue; for(j=i;j;j=i&(j-1)) { if(f[j].empty() || f[i^j].empty())continue; for(t=0;t<(int)f[j].size();t++)f[i].pb(f[j][t]); for(t=0;t<(int)f[i^j].size();t++)f[i].pb(f[i^j][t]); break; } } x=(1<<n)-1; if(f[x].empty())rc("detention"); cout<<"home"<<endl<<(int)f[x].size()<<endl; for(i=0;i<(int)f[x].size();i++) { cout<<__builtin_popcount(f[x][i])<<" "; for(j=0;j<n;j++)if(f[x][i]&(1<<j))cout<<j<<" "; cout<<endl; } return 0; }

Compilation message (stderr)

friends.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
friends.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...