結果

問題 No.2037 NAND Pyramid
ユーザー gew1fw
提出日時 2025-06-12 21:35:58
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 900 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 82,580 KB
実行使用メモリ 52,864 KB
最終ジャッジ日時 2025-06-12 21:38:23
合計ジャッジ時間 4,542 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 3 TLE * 1 -- * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.read().split()
    idx = 0
    N = int(input[idx])
    idx += 1
    K = int(input[idx])
    idx += 1
    S = input[idx]
    
    # Compute for each j, the result of the reduction of S[j:j + (N-K +1)]
    result = []
    for j in range(K):
        end = j + (N - K + 1)
        current_layer = S[j:end]
        
        # Compute the reduction
        while len(current_layer) > 1:
            next_layer = []
            for i in range(len(current_layer) - 1):
                a = int(current_layer[i])
                b = int(current_layer[i+1])
                if a == 1 and b == 1:
                    next_layer.append('0')
                else:
                    next_layer.append('1')
            current_layer = ''.join(next_layer)
        result.append(current_layer[0])
    
    print(''.join(result))

if __name__ == '__main__':
    main()
0