結果
| 問題 |
No.1376 Simple LPS Problem
|
| コンテスト | |
| ユーザー |
milanis48663220
|
| 提出日時 | 2021-02-05 22:52:55 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,867 bytes |
| コンパイル時間 | 1,004 ms |
| コンパイル使用メモリ | 95,388 KB |
| 最終ジャッジ日時 | 2025-01-18 12:50:36 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 60 |
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
int max_pan(string s){
int ans = 1;
int n = s.size();
for(int c = 0; c < n; c++){
for(int l = 1; c-l >= 0 && c+l < n; l++){
if(s[c-l] != s[c+l]) break;
chmax(ans, l*2+1);
}
for(int l = 1; c-l >= 0 && c+l-1 < n; l++){
if(s[c-l] != s[c+l-1]) break;
chmax(ans, l*2);
}
}
return ans;
}
void solve_small(int n, int k){
set<int> st;
for(int i = 0; i < (1<<n); i++){
string s;
for(int j = 0; j < n; j++){
if(i&(1<<j)) s += '1';
else s += '0';
}
// cout << s << ' ' << max_pan(s) << endl;
if(max_pan(s) == k){
cout << s << endl;
return;
}
}
cout << -1 << endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(10) << fixed;
int n, k; cin >> n >> k;
// test();
if(n <= 10){
solve_small(n, k);
return 0;
}
if(k <= 3){
cout << -1 << endl;
return 0;
}
string t = "1";
for(int i = 2; i <= k-1; i++) t += "0";
t += "1";
t += "01";
string ans;
while(ans.size() < n) ans += t;
while(ans.size() > n) ans.pop_back();
cout << ans << endl;
// cout << max_pan(ans) << endl;
}
milanis48663220