結果

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

テストケース

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

ソースコード

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 // 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] = 0
        else:
            ans[0] = 1
else:
    ans[0] = 0
if l[end] == 1:
    if l[end-1] == 1:
        ans[-1] = 1
    else:
        if migi:
            ans[-1] = 0
        else:
            ans[-1] = 1
else:
    ans[-1] = 0
"""
if l[start] == 1:
    if l[start + 1] == 1:
        ans[0] = 1
    else:
        if l[start - 1] == 1:
            ans[0] = 1
        else:
            ans[0] = 0
if l[end] == 1:
    if l[end - 1] == 0 and l[end] + 1 == 0:
        ans[-1] = 0
    else:
        ans[-1] = 1
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 = "")
print(start,end)
0