답안 #288055

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
288055 2020-09-01T08:21:38 Z dvdg6566 "The Lyuboyn" code (IZhO19_lyuboyn) C++14
34 / 100
99 ms 9576 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
#define pb emplace_back
#define mp make_pair
#define f first
#define s second
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(),x.end()
#define lb lower_bound
const int MAXN=1001000;
const ll MOD=998244353;

int N,K,T;
string S;

void tobin(int y,int len){
	string x;
	while(y){
		x+=('0' + y%2);
		y/=2;
	}
	while(SZ(x) < len)x+='0';
	reverse(ALL(x));
	cout<<x;
}

vi A;
vi B;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>N>>K>>T>>S;
	if(K%2==0){
		cout<<-1;
		return 0;
	}

	ll flip=0;
	if(K*2>N){
		K=N-K;
		flip=1;
	}

	ll v=0;ll k=1;
	while(SZ(S)){
		if(S.back() == '1')v+=k;
		k*=2;
		S.pop_back();
	}
	ll mod=(1<<(N-K+1));

	// cerr<<mod<<'\n';

	A.pb(v/mod);

	B.pb(v%mod);

	ll alen=(K-1);
	for(int i=1;i<=(1<<alen);++i){
		for(int j=0;j<mod-1;++j){
			A.pb(A.back() ^ ((1<<alen)-1));
		}
		// flip A back
		if(SZ(A) < (1<<N))A.pb(A.back() ^ (i&(-i)));
	}

	for(int i=1;i<=(1<<alen);++i){
		for(int j=1;j<mod;++j){
			B.pb(B.back() ^ (j&(-j)));
		}
		// flip A back
		if(SZ(B) < (1<<N))B.pb(B.back() ^ ((1<<(K-1))-1));
	}

	cout<<(1<<N)<<'\n';

	for(int i=0;i<SZ(A);++i){
		if(flip&&i%2){
			A[i]=((1<<(K-1))-1)^A[i];
			B[i]=((1<<(N-K+1))-1)^B[i];
		}
		tobin(B[i],(N-K+1));
		tobin(A[i],K-1);
		cout<<'\n';
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Ok
2 Correct 0 ms 384 KB Ok
3 Correct 0 ms 384 KB Ok
4 Correct 1 ms 384 KB Ok
5 Correct 0 ms 384 KB Ok
6 Correct 0 ms 384 KB Ok
7 Correct 0 ms 256 KB Ok
8 Correct 1 ms 384 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 9576 KB Ok
2 Correct 42 ms 4844 KB Ok
3 Correct 1 ms 384 KB Ok
4 Correct 0 ms 384 KB Ok
5 Correct 0 ms 384 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Ok
2 Correct 2 ms 640 KB Ok
3 Correct 35 ms 4840 KB Ok
4 Correct 17 ms 2684 KB Ok
5 Correct 1 ms 384 KB Ok
6 Correct 1 ms 452 KB Ok
7 Correct 9 ms 1532 KB Ok
8 Correct 1 ms 384 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Incorrect 71 ms 9572 KB First number in answer is not x 44202 172722
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 9576 KB Ok
2 Correct 42 ms 4844 KB Ok
3 Correct 1 ms 384 KB Ok
4 Correct 0 ms 384 KB Ok
5 Correct 0 ms 384 KB Ok
6 Correct 0 ms 384 KB Ok
7 Correct 2 ms 640 KB Ok
8 Correct 35 ms 4840 KB Ok
9 Correct 17 ms 2684 KB Ok
10 Correct 1 ms 384 KB Ok
11 Correct 1 ms 452 KB Ok
12 Correct 9 ms 1532 KB Ok
13 Correct 1 ms 384 KB Ok
14 Incorrect 71 ms 9572 KB First number in answer is not x 44202 172722
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 42 ms 4900 KB The values in the output sequence are not pairwise distinct!
2 Halted 0 ms 0 KB -