結果
| 問題 |
No.1376 Simple LPS Problem
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 21:44:25 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 902 bytes |
| コンパイル時間 | 304 ms |
| コンパイル使用メモリ | 81,536 KB |
| 実行使用メモリ | 52,224 KB |
| 最終ジャッジ日時 | 2025-06-12 21:48:54 |
| 合計ジャッジ時間 | 6,846 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 45 WA * 15 |
ソースコード
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)
gew1fw