結果
| 問題 |
No.1376 Simple LPS Problem
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2021-02-05 22:21:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 2,461 bytes |
| コンパイル時間 | 2,672 ms |
| コンパイル使用メモリ | 198,968 KB |
| 最終ジャッジ日時 | 2025-01-18 12:35:52 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 60 |
ソースコード
#include <bits/stdc++.h>
#pragma region my_template
struct Rep {
struct I {
int i;
void operator++() { ++i; }
int operator*() const { return i; }
bool operator!=(I o) const { return i < *o; }
};
const int l_, r_;
Rep(int l, int r) : l_(l), r_(r) {}
Rep(int n) : Rep(0, n) {}
I begin() const { return {l_}; }
I end() const { return {r_}; }
};
struct Per {
struct I {
int i;
void operator++() { --i; }
int operator*() const { return i; }
bool operator!=(I o) const { return i > *o; }
};
const int l_, r_;
Per(int l, int r) : l_(l), r_(r) {}
Per(int n) : Per(0, n) {}
I begin() const { return {r_ - 1}; }
I end() const { return {l_ - 1}; }
};
template <class F>
struct Fix : private F {
Fix(F f) : F(f) {}
template <class... Args>
decltype(auto) operator()(Args&&... args) const {
return F::operator()(*this, std::forward<Args>(args)...);
}
};
template <class T = int>
T scan() {
T res;
std::cin >> res;
return res;
}
template <class T, class U = T>
bool chmin(T& a, U&& b) {
return b < a ? a = std::forward<U>(b), true : false;
}
template <class T, class U = T>
bool chmax(T& a, U&& b) {
return a < b ? a = std::forward<U>(b), true : false;
}
#ifndef LOCAL
#define DUMP(...) void(0)
template <int OnlineJudge, int Local>
constexpr int OjLocal = OnlineJudge;
#endif
using namespace std;
#define ALL(c) begin(c), end(c)
#pragma endregion
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
cout << fixed << setprecision(20);
int n = scan();
int k = scan();
if (n < 16) {
for (int mask : Rep(1 << n)) {
auto same = [&](int i, int j) {
return (mask >> i & 1) == (mask >> j & 1);
};
vector f(n + 1, vector<bool>(n + 1));
int mx = 0;
for (int r : Rep(n + 1))
for (int l : Per(r + 1)) {
if (r - l < 2) {
f[l][r] = true;
} else {
f[l][r] = same(l, r - 1) and f[l + 1][r - 1];
}
if (f[l][r]) chmax(mx, r - l);
}
if (mx == k) {
for (int i : Rep(n)) cout << (mask >> i & 1);
cout << '\n';
exit(0);
}
}
cout << "-1\n";
exit(0);
}
if (k <= 3) {
cout << "-1\n";
exit(0);
}
for (int _ = k; _--;) cout << 0;
for (int i : Rep(n - k)) cout << "110100"[i % 6];
cout << '\n';
}
risujiroh