답안 #218812

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
218812 2020-04-02T19:07:23 Z Lawliet "The Lyuboyn" code (IZhO19_lyuboyn) C++14
5 / 100
390 ms 262148 KB
#include <bits/stdc++.h>

using namespace std;

int n, k, t;

void printBinary(int k)
{
	for(int i = n - 1 ; i >= 0 ; i--)
	{
		if( k & (1 << i) ) printf("1");
		else printf("0");
	}

	printf("\n");
}

int main()
{
	string s;
	cin >> n >> k >> t >> s;

	vector< int > ans;

	ans.push_back( 0 );
	ans.push_back( 1 );

	for(int i = 2 ; i <= 4 ; i++)
	{
		int curSz = ans.size();

		for(int j = 0 ; j < ans.size() ; j++)
			ans[j] = 2*ans[j];

		for(int j = curSz - 1 ; j >= 0 ; j--)
			ans.push_back( ans[j] + 1 );
	}

	for(int i = 1 ; i < ans.size() ; i += 2)
		ans[i] = 15 - ans[i];

	for(int i = 5 ; i <= n ; i++)
	{
		int curSz = ans.size();
		int first = ans.back();

		for(int j = 0 ; j < k - 1 ; j++)
			first ^= (1 << j);

		int indFirst;

		for(int j = 0 ; j < ans.size() ; j++)
			if( ans[j] == first ) indFirst = j;

		for(int j = 0 ; j < ans.size() ; j++)
			ans[j] = 2*ans[j];

		for(int j = indFirst ; j != indFirst - 1 ; j++, j %= curSz)
			ans.push_back( ans[j] + 1 );
	}

	printf("%d\n",(int) ans.size());

	for(int i = 0 ; i < ans.size() ; i++)
		printBinary( ans[i] );
}

Compilation message

lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:32:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0 ; j < ans.size() ; j++)
                   ~~^~~~~~~~~~~~
lyuboyn.cpp:39:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 1 ; i < ans.size() ; i += 2)
                  ~~^~~~~~~~~~~~
lyuboyn.cpp:52:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0 ; j < ans.size() ; j++)
                   ~~^~~~~~~~~~~~
lyuboyn.cpp:55:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0 ; j < ans.size() ; j++)
                   ~~^~~~~~~~~~~~
lyuboyn.cpp:64:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0 ; i < ans.size() ; i++)
                  ~~^~~~~~~~~~~~
lyuboyn.cpp:58:40: warning: 'indFirst' may be used uninitialized in this function [-Wmaybe-uninitialized]
   for(int j = indFirst ; j != indFirst - 1 ; j++, j %= curSz)
                               ~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB The output is neither -1 nor the length of the answer
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Runtime error 381 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 201 ms 6120 KB The output is neither -1 nor the length of the answer
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 390 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 201 ms 6120 KB The output is neither -1 nor the length of the answer
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -