結果

問題 No.2037 NAND Pyramid
ユーザー AngrySadEight
提出日時 2025-02-11 21:25:17
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 417 bytes
コンパイル時間 467 ms
コンパイル使用メモリ 82,764 KB
実行使用メモリ 408,712 KB
最終ジャッジ日時 2025-02-11 21:26:40
合計ジャッジ時間 79,821 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15 TLE * 24
権限があれば一括ダウンロードができます

ソースコード

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 += nands(s[i],s[i+1])
if k==1:
    print(t1)
else:
    for i in range(n-2):
        t2 += nands(t1[i],t1[i+1])
    if k%2==0:
        start=k//2-1
        print(t2[start:start+n-k])
    else:
        start=k//2
        print(t1[start:start+n-k])
0