Submission #336430

# Submission time Handle Problem Language Result Execution time Memory
336430 2020-12-15T10:20:05 Z amunduzbaev "The Lyuboyn" code (IZhO19_lyuboyn) C++14
19 / 100
1000 ms 123012 KB
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
//#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ll long long 
#define ld long double 
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define prc(n) fixed << setprecision(n)
#define fastios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi acos(-1);
const int inf = 1e9+7;
const int N = 105;
 
int n, m, t, a;
 
string bin(int a){
	string s;
	while(a){
		s.pb(char((a%2) + '0'));
		a/=2;
	}
	while(sz(s) < n) s.pb('0');
	reverse(all(s));
	return s;
}
 
map<int, int> mp;
 
void rec(vector<int> order, int last){
	if(last == (1<<n)){
		if(t && __builtin_popcount(order[0] ^ order[last-1]) != m) return;
		cout<<(1<<n)<<"\n";
		for(int i=0;i<(1<<n);i++){
			cout<<bin(order[i])<<"\n";
		}
		exit(0);
	}
	for(int i=0;i<(1<<n);i++){
		if(mp[i] == 0){
			//cout<<i<<"\n";
			bool ok = 1;
			if(__builtin_popcount(order[last-1] ^ i) != m) ok = 0;
			//cout<<__builtin_popcount(order[last-1] ^ i)<<" "<<order[last-1]<<" "<<i<<"\n";
			if(ok){
				mp[i] = 1;
				order.pb(i);
				rec(order, last+1);
				order.pop_back();
				mp[i] = 0;
			}
		}	
	}
}
 
int main(){
	cin>>n>>m>>t;
	if(m%2 == 0){
		cout<<-1;
		return 0;
	}
	string s;
	cin>>s;
	if(m == 1){
		vector<int>ans = {0, 1};
		while(sz(ans) < (1<<n)){
			//cout<<sz(ans)<<"\n";
			int add = sz(ans), size = sz(ans);
			for(int i = size-1; i>=0; i--)
				ans.pb(ans[i] + add);
		}
		cout<<(1<<n)<<"\n";
		for(int i=0;i<(1<<n);i++)
			cout<<bin(ans[i])<<"\n";
		return 0;
	}
	reverse(all(s));
	for(int i=0;i<sz(s);i++)
		if(s[i] == '1') a += (1<<i);
	mp[a] = 1;
	rec({a}, 1);
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB First number in answer is not x 1 0
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Ok
2 Correct 1 ms 364 KB Ok
3 Correct 1 ms 364 KB Ok
4 Correct 1 ms 364 KB Ok
5 Correct 1 ms 364 KB Ok
6 Correct 1 ms 364 KB Ok
7 Correct 1 ms 364 KB Ok
8 Correct 0 ms 364 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 77 ms 6768 KB Ok
2 Correct 38 ms 3300 KB Ok
3 Correct 1 ms 364 KB Ok
4 Correct 1 ms 364 KB Ok
5 Correct 1 ms 364 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Ok
2 Execution timed out 1094 ms 121840 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1098 ms 123012 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 77 ms 6768 KB Ok
2 Correct 38 ms 3300 KB Ok
3 Correct 1 ms 364 KB Ok
4 Correct 1 ms 364 KB Ok
5 Correct 1 ms 364 KB Ok
6 Correct 1 ms 364 KB Ok
7 Execution timed out 1094 ms 121840 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 4076 KB Time limit exceeded
2 Halted 0 ms 0 KB -