結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー rlangevinrlangevin
提出日時 2023-10-19 21:14:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,179 bytes
コンパイル時間 603 ms
コンパイル使用メモリ 81,672 KB
実行使用メモリ 77,920 KB
最終ジャッジ日時 2023-10-19 21:14:16
合計ジャッジ時間 12,073 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 42 ms
55,800 KB
testcase_05 AC 43 ms
55,580 KB
testcase_06 AC 42 ms
55,800 KB
testcase_07 AC 43 ms
55,800 KB
testcase_08 AC 233 ms
73,004 KB
testcase_09 AC 42 ms
55,800 KB
testcase_10 AC 42 ms
55,800 KB
testcase_11 AC 42 ms
55,800 KB
testcase_12 AC 97 ms
66,384 KB
testcase_13 AC 42 ms
55,800 KB
testcase_14 AC 43 ms
55,800 KB
testcase_15 AC 43 ms
55,800 KB
testcase_16 AC 43 ms
55,800 KB
testcase_17 AC 43 ms
55,800 KB
testcase_18 AC 43 ms
55,800 KB
testcase_19 WA -
testcase_20 AC 42 ms
55,800 KB
testcase_21 AC 43 ms
55,800 KB
testcase_22 AC 42 ms
55,800 KB
testcase_23 AC 43 ms
55,800 KB
testcase_24 AC 42 ms
55,800 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 42 ms
55,800 KB
testcase_28 AC 43 ms
55,800 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 43 ms
55,800 KB
testcase_32 AC 72 ms
64,212 KB
testcase_33 AC 59 ms
72,500 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 533 ms
77,068 KB
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *

def main():
    N = int(input())
    M = int(N ** 0.5) + 2
    inf = 10 ** 18
    dp = [inf] * (N + 1)
    dp[0] = 0
    for i in range(N):
        for j in range(1, M + 1):
            nex = i + j * j
            if i + j * j > N:
                break
            dp[nex] = min(dp[nex], dp[i] + 1)
    
    L = []
    while N:
        if N >= M * M:
            if dp[N] == dp[N - M * M] + 1:
                N -= M * M
                L.append(M)
                continue
        M -= 1

    def f(t):
        odd, even = [], []
        for i in range(len(t)):
            if t[i] % 2:
                odd.append(t[i])
            else:
                even.append(t[i])
        odd.sort()
        even.sort()
        even = deque(even)
        cnt = 0
        while even:
            if cnt % 2:
                odd.append(even.popleft())
            else:
                odd.append(even.pop())
            cnt += 1
        lst = []
        now = 0
        for a in odd:
            for i in range(a):
                lst.append(str(now))
                now = 1 - now
            now = 1 - now
        return "".join(lst)

    print(f(L))

main()
0