結果

問題 No.1376 Simple LPS Problem
ユーザー gew1fw
提出日時 2025-06-12 16:59:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 902 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 52,480 KB
最終ジャッジ日時 2025-06-12 16:59:35
合計ジャッジ時間 5,942 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 45 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())

if k == 1:
    if n == 1:
        print('0')
    elif n == 2:
        print('01')
    else:
        print(-1)
else:
    if k < (n // 2 + 1):
        print(-1)
    else:
        if k % 2 == 0:
            half = k // 2
            first_half = '0' * (half - 1) + '1'
            second_half = first_half[::-1]
            palindrome = first_half + second_half
        else:
            middle = '0'
            half = (k - 1) // 2
            first_half = '1' * half
            second_half = first_half[::-1]
            palindrome = first_half + middle + second_half
        
        remaining = n - k
        if remaining > 0:
            if palindrome[0] == '0':
                next_char = '1'
            else:
                next_char = '0'
            s = palindrome + next_char + '0' * (remaining - 1)
        else:
            s = palindrome
        print(s)
0