結果

問題 No.2037 NAND Pyramid
ユーザー ああいいああいい
提出日時 2022-08-14 12:36:58
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,310 bytes
コンパイル時間 391 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 255,708 KB
最終ジャッジ日時 2024-04-08 12:04:35
合計ジャッジ時間 7,652 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 41 ms
53,460 KB
testcase_03 WA -
testcase_04 AC 39 ms
53,460 KB
testcase_05 AC 38 ms
53,460 KB
testcase_06 AC 39 ms
53,460 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 WA -
testcase_22 WA -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 AC 316 ms
255,708 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys


def calc(l):
    ans = []
    for i in range(len(l) - 1):
        ans.append(1 - (l[i] & l[i+1]))
    return ans

N,K = map(int,input().split())
K = N - K
S = input()
l = list(S)
l = list(map(int,l))
if K % 2 == 1:
    ll = []
    for i in range(N - 1):
        ll.append(1 - l[i] & l[i+1])
    l = ll
    K -= 1
    N -= 1
if K == 0:
    print(*l,sep = "")
    exit()

if K <= 20 or N <= 20:
    for _ in range(K):
        l = calc(l)
    print(*l,sep = "")
    exit()

u = (K - len(l)) // 2
start = u
end = N - u - 1

ans = [0] * (N - K)

hidari = False
migi = False
for i in range(u):
    if l[i] == 0:
        hidari = True
        break
for i in range(end + 1,N):
    if l[i] == 0:
        migi = True
        break
if l[start] == 1:
    if l[u+1] == 1:
        ans[0] = 1
    else:
        if hidari:
            ans[0] = 1
        else:
            ans[0] = 0
else:
    ans[0] = 0
if l[end] == 1:
    if l[end-1] == 1:
        ans[-1] = 1
    else:
        if migi:
            ans[-1] = 1
        else:
            ans[-1] = 0
else:
    ans[-1] = 0
for i in range(1,N - K - 1):
    if l[start+i] == 0:
        ans[i] = 0
        continue
    else:
        if l[start + i - 1] == 0 and l[start + i + 1] == 0:
            ans[i] = 0
        else:
            ans[i] = 1
print(*ans,sep = "")
0