結果

問題 No.1376 Simple LPS Problem
ユーザー leaf_1415leaf_1415
提出日時 2020-10-13 00:48:23
言語 C++11
(gcc 11.4.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,074 bytes
コンパイル時間 489 ms
コンパイル使用メモリ 64,284 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-30 01:46:11
合計ジャッジ時間 7,785 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 1 ms
4,384 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 RE -
testcase_55 RE -
testcase_56 RE -
testcase_57 RE -
testcase_58 RE -
testcase_59 RE -
testcase_60 RE -
testcase_61 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <cassert>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

int n, k;

int calc(string &s)
{
	int ret = 0;
	for(int i = 0; i < s.size(); i++){
		for(int j = 0; ; j++){
			if(i+j >= s.size() || i-j < 0) break;
			if(s[i+j] != s[i-j]) break;
			ret = max(ret, 2*j+1);
		}
	}
	for(int i = 1; i < s.size(); i++){
		if(s[i-1] != s[i]) continue;
		for(int j = 0; ; j++){
			if(i+j >= s.size() || i-j-1 < 0) break;
			if(s[i+j] != s[i-j-1]) break;
			ret = max(ret, 2*j+2);
		}
	}
	return ret;
}

int main()
{
	cin >> n >> k;
	assert(1 <= k && k <= n && n <= 1000);
	
	if(n <= 8){
		int N = 1 << n;
		for(int i = 0; i < N; i++){
			string s;
			for(int j = 0; j < n; j++) s += ((i>>j)&1) + '0';
			if(calc(s) == k){
				cout << s << endl;
				return 0;
			}
		}
		cout << -1 << endl;
	}
	else{
		if(k < 4){
			cout << -1 << endl;
			return 0;
		}
		string s;
		for(int i = 0; i < k; i++) s += '1';
		for(int i = 0; i < 1000; i++) s += "010011";
		s = s.substr(0, n);
		cout << s << endl;
	}
	
	return 0;
}
0