結果

問題 No.2037 NAND Pyramid
ユーザー 👑 KazunKazun
提出日時 2022-08-12 23:32:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 731 bytes
コンパイル時間 848 ms
コンパイル使用メモリ 81,756 KB
実行使用メモリ 110,596 KB
最終ジャッジ日時 2023-10-24 11:53:32
合計ジャッジ時間 5,975 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,544 KB
testcase_01 AC 36 ms
53,544 KB
testcase_02 AC 35 ms
53,544 KB
testcase_03 AC 36 ms
53,544 KB
testcase_04 AC 36 ms
53,544 KB
testcase_05 AC 36 ms
53,544 KB
testcase_06 AC 36 ms
53,544 KB
testcase_07 AC 99 ms
105,580 KB
testcase_08 AC 84 ms
103,804 KB
testcase_09 AC 93 ms
102,616 KB
testcase_10 AC 60 ms
86,872 KB
testcase_11 AC 99 ms
105,024 KB
testcase_12 AC 78 ms
90,020 KB
testcase_13 AC 59 ms
77,240 KB
testcase_14 AC 81 ms
95,948 KB
testcase_15 AC 93 ms
104,612 KB
testcase_16 AC 79 ms
95,164 KB
testcase_17 AC 80 ms
110,596 KB
testcase_18 AC 80 ms
110,596 KB
testcase_19 AC 110 ms
110,596 KB
testcase_20 AC 110 ms
110,596 KB
testcase_21 AC 132 ms
110,596 KB
testcase_22 AC 130 ms
110,596 KB
testcase_23 AC 130 ms
110,596 KB
testcase_24 AC 129 ms
110,596 KB
testcase_25 AC 79 ms
110,596 KB
testcase_26 AC 79 ms
110,596 KB
testcase_27 AC 107 ms
110,596 KB
testcase_28 AC 81 ms
110,596 KB
testcase_29 AC 81 ms
110,596 KB
testcase_30 AC 130 ms
110,596 KB
testcase_31 AC 109 ms
110,596 KB
testcase_32 AC 109 ms
110,596 KB
testcase_33 AC 43 ms
59,664 KB
testcase_34 AC 47 ms
64,444 KB
testcase_35 AC 47 ms
64,444 KB
testcase_36 AC 48 ms
64,444 KB
testcase_37 AC 48 ms
64,444 KB
testcase_38 AC 48 ms
64,444 KB
testcase_39 AC 49 ms
64,444 KB
testcase_40 AC 43 ms
59,664 KB
testcase_41 AC 42 ms
59,664 KB
testcase_42 AC 42 ms
59,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Run_Length_Encoding(S):
    """ランレングス圧縮

    S:文字列
    """
    if not S:
        return []

    R=[[S[0],1]]

    for i in range(1,len(S)):
        if R[-1][0]==S[i]:
            R[-1][1]+=1
        else:
            R.append([S[i],1])

    return R
#==================================================
def solve():
    N,K=map(int,input().split())
    S=list(map(int,input()))

    A=[0]*(N-1); B=[0]*(N-2)
    for i in range(N-1):
        A[i]=1-S[i]*S[i+1]
    for i in range(N-2):
        B[i]=1-A[i]*A[i+1]

    if len(B)%2==0:
        A,B=B,A

    if K%2==0:
        t=(len(A)-K)//2
        Ans=A[t:len(A)-t]
    else:
        t=(len(B)-K)//2
        Ans=B[t:len(B)-t]
    print(*Ans,sep="")

solve()
0