답안 #336467

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
336467 2020-12-15T11:37:01 Z amunduzbaev "The Lyuboyn" code (IZhO19_lyuboyn) C++14
8 / 100
86 ms 6496 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, k, 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;
}

int main(){
	cin>>n>>k>>t;
	if(k%2 == 0){
		cout<<-1;
		return 0;
	}
	string s;
	cin>>s;
	reverse(all(s));
	
	for(int i=0;i<sz(s);i++)
		if(s[i] == '1') a += (1<<i);
	
	vector<int>ans = {0, 1};
	int mx = (1<<(k+1)) - 1;
	while(sz(ans) < (1<<(k+1))){
		int add = sz(ans), size = sz(ans);
		for(int i = size-1; i>=0; i--)
			ans.pb(ans[i] + add);
	}
	if(sz(ans) == (1<<n)){
		for(int i = 0; i< sz(ans); i++)
			if(i % 2 == 0) ans[i] = (mx ^ ans[i]);
	}
	else{
		while(sz(ans) < (1<<n)){
			int add = sz(ans), size = sz(ans);
			for(int i = size-1; i>=0; i--)
				ans.pb(ans[i] + add);
			for(int i = 0; i< sz(ans); i++)
				if(i % 2 == 0) ans[i] = (mx ^ ans[i]);
			mx++;
		}
	}
	int start;
	for(int i=0;i<(1<<n);i++){
		if(ans[i] == a) start = i;
	}
	
	cout<<(1<<n)<<"\n";
	int size = (1<<n);
	for(int i=start+1;i != start;i++){
		if(i == size+1) i = 1;
		cout<<bin(ans[i-1])<<"\n";
	}
	cout<<bin(ans[start-1])<<"\n";
	
	return 0;
}

Compilation message

lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:82:21: warning: 'start' may be used uninitialized in this function [-Wmaybe-uninitialized]
   82 |  cout<<bin(ans[start-1])<<"\n";
      |                ~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Ok
2 Correct 0 ms 364 KB Ok
3 Correct 1 ms 384 KB Ok
4 Correct 0 ms 364 KB Ok
5 Correct 0 ms 364 KB Ok
6 Correct 0 ms 364 KB Ok
7 Correct 1 ms 384 KB Ok
8 Correct 0 ms 364 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Incorrect 84 ms 6496 KB Fail, not exactly k bits are different: line = 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 86 ms 6484 KB Fail, not exactly k bits are different: line = 5
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 84 ms 6496 KB Fail, not exactly k bits are different: line = 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 38 ms 3300 KB Fail, not exactly k bits are different: line = 9014
2 Halted 0 ms 0 KB -