結果

問題 No.1376 Simple LPS Problem
ユーザー leaf_1415leaf_1415
提出日時 2020-10-13 00:54:14
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,173 bytes
コンパイル時間 714 ms
コンパイル使用メモリ 67,468 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-30 01:47:21
合計ジャッジ時間 9,912 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 2 ms
4,504 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 1 ms
4,376 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 2 ms
4,380 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>
#include <algorithm>

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){
				reverse(s.begin(), s.end());
				s += '0';
				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);
		reverse(s.begin(), s.end());
		cout << s << endl;
	}
	
	return 0;
}
0