Submission #162679

# Submission time Handle Problem Language Result Execution time Memory
162679 2019-11-09T08:44:02 Z MvC Friends (BOI17_friends) C++11
0 / 100
6 ms 3704 KB
#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;
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>>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

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 time Memory Grader output
1 Correct 4 ms 1912 KB Output is correct
2 Incorrect 4 ms 1912 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1912 KB Output is correct
2 Runtime error 6 ms 3704 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1912 KB Output is correct
2 Runtime error 6 ms 3704 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1912 KB Output is correct
2 Incorrect 4 ms 1912 KB Output isn't correct
3 Halted 0 ms 0 KB -