結果
問題 | No.1376 Simple LPS Problem |
ユーザー | tkmst201 |
提出日時 | 2021-02-10 12:05:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,458 bytes |
コンパイル時間 | 2,031 ms |
コンパイル使用メモリ | 193,832 KB |
最終ジャッジ日時 | 2025-01-18 16:59:46 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 60 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) begin(v),end(v) template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } using ll = long long; using pii = pair<int, int>; constexpr ll INF = 1ll<<30; constexpr ll longINF = 1ll<<60; constexpr ll MOD = 1000000007; constexpr bool debug = false; //---------------------------------// int main() { int N, K; cin >> N >> K; if (N <= 8) { REP(i, 1 << N) { int cur = 1; REP(j, N) { FOR(k, 1, N) { int l = j - k, r = j + k; if (l < 0 || r >= N) break; if ((i >> l & 1) == (i >> r & 1)) chmax(cur, k * 2 + 1); else break; } FOR(k, 0, N) { int l = j - k, r = j + k + 1; if (l < 0 || r >= N) break; if ((i >> l & 1) == (i >> r & 1)) chmax(cur, (k + 1) * 2); else break; } } if (cur == K) { REP(j, N) putchar(i >> j & 1 ? '1' : '0'); puts(""); return 0; } } puts("-1"); } else { if (K < 4) puts("-1"); else { string ans(K, '0'); if (ans.size() < N) ans += '1'; if (ans.size() < N) ans += '0'; const string s = "110010110010"; const int dif = N - ans.size(); REP(i, dif) ans += s[i % s.size()]; cout << ans << endl; } } }