結果
| 問題 |
No.1376 Simple LPS Problem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-04-16 17:18:28 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 108 ms / 2,000 ms |
| コード長 | 1,040 bytes |
| コンパイル時間 | 217 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 101,040 KB |
| 最終ジャッジ日時 | 2024-12-25 21:11:41 |
| 合計ジャッジ時間 | 5,313 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 60 |
ソースコード
def manacher(S):
T = []
for s in S:
T += [s, chr(1)]
T.pop()
n = len(T)
L = [0] * n
i = j = 0
while i < n:
while i >= j and i + j < n and T[i - j] == T[i + j]:
j += 1
L[i] = j
k = 1
while k + L[i - k] < j and k <= i and i + k < n:
L[i + k] = L[i - k]
k += 1
i += k
j -= k
for i, l in enumerate(L):
l = 2 * l - 1
if i % 2 == 0:
L[i] = 2 * (l // 4) + 1
else:
l += 1
L[i] = 2 * (l // 4)
return L
n, k = map(int, input().split())
if n <= 15:
for bit in range(1 << n):
S = bin(bit)[2:].zfill(n)
x = max(manacher(S))
if k == x:
print(S)
exit()
print(-1)
exit()
if k <= 3:
print(-1)
exit()
S = ["0"] * k
T = "101100"
p = 0
while len(S) < n:
S.append(T[p])
p += 1
if p == 6:
p = 0
print(*S, sep="")
assert max(manacher(S)) == k