結果

問題 No.1376 Simple LPS Problem
ユーザー 👑 rin204rin204
提出日時 2022-04-16 17:18:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 1,040 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 102,348 KB
最終ジャッジ日時 2023-08-26 19:38:49
合計ジャッジ時間 8,408 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,192 KB
testcase_01 AC 108 ms
77,008 KB
testcase_02 AC 64 ms
71,204 KB
testcase_03 AC 65 ms
71,260 KB
testcase_04 AC 66 ms
71,072 KB
testcase_05 AC 61 ms
71,408 KB
testcase_06 AC 63 ms
71,396 KB
testcase_07 AC 64 ms
71,360 KB
testcase_08 AC 63 ms
71,172 KB
testcase_09 AC 64 ms
71,092 KB
testcase_10 AC 63 ms
71,056 KB
testcase_11 AC 67 ms
71,560 KB
testcase_12 AC 66 ms
71,348 KB
testcase_13 AC 65 ms
71,256 KB
testcase_14 AC 67 ms
71,344 KB
testcase_15 AC 67 ms
71,344 KB
testcase_16 AC 67 ms
71,452 KB
testcase_17 AC 67 ms
71,488 KB
testcase_18 AC 65 ms
71,200 KB
testcase_19 AC 63 ms
71,372 KB
testcase_20 AC 66 ms
71,192 KB
testcase_21 AC 66 ms
71,156 KB
testcase_22 AC 64 ms
71,484 KB
testcase_23 AC 75 ms
75,924 KB
testcase_24 AC 79 ms
75,848 KB
testcase_25 AC 69 ms
71,196 KB
testcase_26 AC 68 ms
71,092 KB
testcase_27 AC 66 ms
71,348 KB
testcase_28 AC 80 ms
76,456 KB
testcase_29 AC 79 ms
76,212 KB
testcase_30 AC 65 ms
71,088 KB
testcase_31 AC 64 ms
71,188 KB
testcase_32 AC 65 ms
71,400 KB
testcase_33 AC 66 ms
71,284 KB
testcase_34 AC 89 ms
77,104 KB
testcase_35 AC 89 ms
76,924 KB
testcase_36 AC 90 ms
77,096 KB
testcase_37 AC 64 ms
71,172 KB
testcase_38 AC 64 ms
71,456 KB
testcase_39 AC 63 ms
71,236 KB
testcase_40 AC 64 ms
71,432 KB
testcase_41 AC 64 ms
71,064 KB
testcase_42 AC 141 ms
102,348 KB
testcase_43 AC 111 ms
94,552 KB
testcase_44 AC 62 ms
71,256 KB
testcase_45 AC 94 ms
81,032 KB
testcase_46 AC 122 ms
96,308 KB
testcase_47 AC 103 ms
86,312 KB
testcase_48 AC 113 ms
87,908 KB
testcase_49 AC 88 ms
77,424 KB
testcase_50 AC 93 ms
82,536 KB
testcase_51 AC 112 ms
91,296 KB
testcase_52 AC 106 ms
90,184 KB
testcase_53 AC 126 ms
99,944 KB
testcase_54 AC 111 ms
92,172 KB
testcase_55 AC 64 ms
71,136 KB
testcase_56 AC 61 ms
71,068 KB
testcase_57 AC 63 ms
71,268 KB
testcase_58 AC 86 ms
81,192 KB
testcase_59 AC 99 ms
89,008 KB
testcase_60 AC 63 ms
71,408 KB
testcase_61 AC 63 ms
71,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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



0