結果

問題 No.2037 NAND Pyramid
ユーザー AngrySadEight
提出日時 2025-02-11 21:32:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 445 bytes
コンパイル時間 395 ms
コンパイル使用メモリ 82,904 KB
実行使用メモリ 130,724 KB
最終ジャッジ日時 2025-02-11 21:32:22
合計ジャッジ時間 5,702 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 36 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

def nands(c1,c2):
    if c1=='1' and c2=='1':
        return '0'
    return '1'

n,k=map(int,input().split())
s=str(input())
k=n-k

t1=[]
t2=[]
for i in range(n-1):
    t1.append(nands(s[i],s[i+1]))
if k==1:
    print(t1)
else:
    for i in range(n-2):
        t2.append(nands(t1[i],t1[i+1]))
    if k%2==0:
        start=k//2-1
        print(''.join(t2[start:start+n-k]))
    else:
        start=k//2
        print(''.join(t1[start:start+n-k]))
0