답안 #341530

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341530 2020-12-29T23:05:40 Z ogibogi2004 "The Lyuboyn" code (IZhO19_lyuboyn) C++14
19 / 100
809 ms 19948 KB
#include<bits/stdc++.h>
using namespace std;
int a[1000000];
int xr[1000000];
int n,k,t;
void print(int x)
{
	string s="";
	while(x)
	{
		s+=char('0'+x%2);
		x/=2;
	}
	while(s.size()<n)s+="0";
	reverse(s.begin(),s.end());
	cout<<s<<endl;
}
int main()
{
	cin>>n>>k>>t;
	int one=(1<<n)-(1<<(n-k));
	for(int i=1;i<=(1<<n);i++)
	{
		int t=one;
		int i1=i;
		while(i1%2==0)
		{
			if(i1==2&&i==(1<<n))break;
			if(t&(1<<(n-1)))
			{
				t-=(1<<(n-1));
				t*=2;
				t++;
			}
			else t*=2;
			i1/=2;
		}
		a[i]=t;
	}
	set<int>s;
	for(int i=1;i<=(1<<n);i++)
	{
		xr[i]=xr[i-1]^a[i];
		//cout<<a[i]<<" "<<xr[i]<<endl;
		s.insert(xr[i]);
	}
	if(s.size()!=(1<<n))
	{
		cout<<"-1\n";
		return 0;
	}
	string str;
	cin>>str;
	int b=0;
	for(int i=0;i<str.size();i++)
	{
		if(str[i]=='1')
		{
			b+=(1<<(n-i-1));
		}
	}
	cout<<(1<<n)<<endl;
	print(b);
	for(int i=1;i<(1<<n);i++)
	{
		b^=a[i];
		print(b);
	}
return 0;
}

Compilation message

lyuboyn.cpp: In function 'void print(int)':
lyuboyn.cpp:14:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   14 |  while(s.size()<n)s+="0";
      |        ~~~~~~~~^~
lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:47:13: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |  if(s.size()!=(1<<n))
      |     ~~~~~~~~^~~~~~~~
lyuboyn.cpp:55:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |  for(int i=0;i<str.size();i++)
      |              ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 620 KB Ok
2 Correct 31 ms 5484 KB Ok
3 Correct 29 ms 4460 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 2 ms 620 KB Ok
8 Correct 23 ms 4460 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 672 ms 19652 KB Ok
2 Correct 344 ms 9964 KB Ok
3 Correct 3 ms 364 KB Ok
4 Correct 1 ms 364 KB Ok
5 Correct 1 ms 364 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Ok
2 Correct 21 ms 876 KB Ok
3 Correct 345 ms 9936 KB Ok
4 Correct 187 ms 5100 KB Ok
5 Incorrect 1 ms 364 KB Output -1 while solution exists
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 736 ms 19820 KB Ok
2 Correct 809 ms 19948 KB Ok
3 Incorrect 30 ms 5484 KB Output -1 while solution exists
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 672 ms 19652 KB Ok
2 Correct 344 ms 9964 KB Ok
3 Correct 3 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 21 ms 876 KB Ok
8 Correct 345 ms 9936 KB Ok
9 Correct 187 ms 5100 KB Ok
10 Incorrect 1 ms 364 KB Output -1 while solution exists
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 343 ms 9836 KB Ok
2 Correct 697 ms 19820 KB Ok
3 Correct 720 ms 19880 KB Ok
4 Correct 42 ms 1516 KB Ok
5 Correct 2 ms 364 KB Ok
6 Correct 83 ms 2668 KB Ok
7 Correct 725 ms 19820 KB Ok
8 Incorrect 1 ms 364 KB Output -1 while solution exists
9 Halted 0 ms 0 KB -