結果

問題 No.1376 Simple LPS Problem
ユーザー Example0911
提出日時 2021-02-15 19:06:29
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 996 bytes
コンパイル時間 1,789 ms
コンパイル使用メモリ 195,764 KB
最終ジャッジ日時 2025-01-18 21:12:28
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 60
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using P = pair<ll, ll>;
const ll INF = (1LL << 61);
ll mod = 998244353;

int N, K;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> K;
	if (N <= 8) {
		for (int bit = 0; bit < (1 << N); bit++) {
			string s = "";
			for (int i = 0; i < N; i++) {
				if (bit & (1 << i))s += '1';
				else s += '0';
			}
			int res = 0;
			for (int i = 0; i < N; i++) {
				string now = "";
				for (int j = i; j < N; j++) {
					now += s[j];
					string tmp = now;
					reverse(now.begin(), now.end());
					if (now == tmp) {
						res = max(res, (int)now.size());
					}
					now = tmp;
				}
			}
			if (res == K) {
				cout << s << endl; return 0;
			}
		}
		cout << -1 << endl;
	}
	else {
		string s = "";
		if (K <= 3)cout << -1 << endl;
		else {
			for (int i = 0; i < K; i++) {
				s += '1';
			}
			for (int i = 0; i < 100010; i++) {
				s += "010011";
			}
			cout << s.substr(0, N) << endl;
		}
	}
	return 0;
}
0