Submission #161902

# Submission time Handle Problem Language Result Execution time Memory
161902 2019-11-05T09:05:07 Z MvC "The Lyuboyn" code (IZhO19_lyuboyn) C++11
3 / 100
48 ms 2676 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=1e6+50;
const int mod=1e9+7;
using namespace std;
int n,k,tp,i,j,t,s,msk,a[nmax],nr,rs,v[nmax];
vector<int>vc;
char c;
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>>k>>tp;
	for(i=0;i<n;i++)
	{
		cin>>c;
		if(c=='1')s|=(1<<(n-i-1));
	}
	for(i=0;i<(1<<n);i++)
	{
		if(__builtin_popcount(i)==k)a[j++]=i;
	}
	shuffle(a,a+j,rng);
	v[s]=1;
	vc.pb(s);
	for(i=1;i<(1<<n);i++)
	{
		nr=0;
		while(v[s^msk^a[t]] && nr<=(1<<n))t=(t+1)%j,nr++;
		if(nr>(1<<n))rc(-1);
		msk^=a[t];
		vc.pb(s^msk);
		v[s^msk]=1;
	}
	rs=(1<<n);
	cout<<rs<<endl;
	for(i=0;i<rs;i++)
	{
		for(j=n-1;j>=0;j--)
		{
			if(vc[i]&(1<<j))cout<<1;
			else cout<<0;
		}
		cout<<'\n';
	}
	return 0;
}

Compilation message

lyuboyn.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
lyuboyn.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Ok
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Not a cycle!
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Ok
2 Correct 15 ms 2040 KB Ok
3 Correct 14 ms 1320 KB Ok
4 Correct 2 ms 376 KB Ok
5 Correct 2 ms 376 KB Ok
6 Correct 2 ms 376 KB Ok
7 Correct 3 ms 376 KB Ok
8 Correct 20 ms 1272 KB Ok
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 2548 KB Output -1 while solution exists
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output -1 while solution exists
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 2676 KB Output -1 while solution exists
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 2548 KB Output -1 while solution exists
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 1528 KB Output -1 while solution exists
2 Halted 0 ms 0 KB -