Problem:


Score : 500 points

Problem Statement

We have N bulbs arranged on a number line, numbered 1 to N from left to right.
Bulb i is at coordinate i.

Each bulb has a non-negative integer parameter called intensity.
When there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5.
Initially, the intensity of Bulb i is A_i. We will now do the following operation K times in a row:

For each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i.

Find the intensity of each bulb after the K operations.

Constraints

1 \leq N \leq 2 \times 10^5

1 \leq K \leq 2 \times 10^5

0 \leq A_i \leq N

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 \ldots A_N

Output

Print the intensity A{'}_i of each bulb i after the K operations to Standard Output in the following format:

A{'}_1 A{'}_2 \ldots A{'}_N

Sample Input 1

5 1
1 0 0 1 0

Sample Output 1

1 2 2 1 2 

Initially, only Bulb 1 illuminates coordinate 1, so the intensity of Bulb 1 becomes 1 after the operation.
Similarly, the bulbs initially illuminating coordinate 2 are Bulb 1 and 2, so the intensity of Bulb 2 becomes 2.

Sample Input 2

5 2
1 0 0 1 0

Sample Output 2

3 3 4 4 3 



Sample input:
5 1
1 0 0 1 0


Sample output:
1 2 2 1 2

Submission status: Runtime Error

Solution code:
import sys
import copy
from numba import njit

def I(): return int(sys.stdin.readline().rstrip())
def LI():return list(map(int,sys.stdin.readline().rstrip().split()))
def LS():return list(sys.stdin.readline().rstrip().split())

@njit('i8,i8,i8[::1]',cache=True)
def main(N,K,A):
    #print(N,K)
    #print(A)

    for k in range(K):
        B = [0]*N
        for i, a in enumerate(A):
            #print(i, a)
            if a == 0:
                B[i] += 1
            else:
                # i-(a+0.5) ~ i+(a+0.5)
                # i: 整数、a: ＋整数　なので +0.5 は切り捨てられる。
                #　影響範囲は、 i-a ~ i+a
                for p in range(i-a,i+a+1):
                    #print("p:",p)
                    if p >=0 and p < N:
                        B[p] += 1
                #print(B)
        if k < K-1:
            A = B
        else:
          break
    return B




if __name__ == '__main__':
    N,K = LI()[:]
    A = LI()
    B = main(N,K,A)
    print(B)

Submission status: Runtime Error

Solution code:
import numpy as np

# Get input
N, K = [int(v) for v in input().split(" ")]
A_arr = np.array([int(v) for v in input().split(" ")])
step = np.arange(len(A_arr))

# Trivial solution
if K > N//2+11:
  print(" ".join([str(N)]*N))
  exit()

def get_Intensity(A_arr):
  inten = np.zeros(len(A_arr))
  for i in range(len(A_arr)):
    isLuminated = np.abs(step - i) < A_arr
    inten[i] = np.sum(isLuminated)
  return inten

Intensity = A_arr
for i in range(K):
  Intensity = get_Intensity(Intensity+1)
  # Termination of calculation (stable solution)
  if np.sum(Intensity) == N**2:
    break
#print(" ".join([str(v) for v in Intensity.astype(int)]))
print(' '.join(map(str, A)))

Submission status: Runtime Error

Solution code:
import math
from sys import stdin,stdout
#% 998244353
from heapq import heapify,heappop,heappush
import collections

n,k=list(map(int,stdin.readline().split()))
a=list(map(int,stdin.readline().split()))


for i in range(min(k,math.log(n))):
    #nw=[0]*n
    pr=[0]*n
    for x,d in enumerate(a):
        if d==0:
            pr[x]+=1
            if x!=n-1:
                pr[x+1]-=1
            continue
        l=math.floor(x-d)
        r=math.floor(x+d)
        l=max(0,l)
        r=min(n-1,r)
        pr[l]+=1
        if r!=n-1:
            pr[r+1]-=1
    
    for m in range(1,n):
        pr[m]+=pr[m-1]
    
    a[:]=pr


        

for i in a:
    print(i,end=" ")

Submission status: Runtime Error

Solution code:
import sys
import copy
from numba import njit

def I(): return int(sys.stdin.readline().rstrip())
def LI():return list(map(int,sys.stdin.readline().rstrip().split()))
def LS():return list(sys.stdin.readline().rstrip().split())

@njit('i8,i8,i8[::1]',cache=True)
def main(N,K,A):
    #print(N,K)
    #print(A)

    for k in range(K):
        B = [0]*N
        for i, a in enumerate(A):
            #print(i, a)
            if a == 0:
                B[i] += 1
            else:
                # i-(a+0.5) ~ i+(a+0.5)
                # i: 整数、a: ＋整数　なので +0.5 は切り捨てられる。
                #　影響範囲は、 i-a ~ i+a
                for p in range(i-a,i+a+1):
                    #print("p:",p)
                    if p >=0 and p < N:
                        B[p] += 1
                #print(B)
        if k < K-1:
            A = B
        else:
            return B




if __name__ == '__main__':
    N,K = LI()[:]
    A = LI()
    B = main(N,K,A)
    print(B)

Submission status: Runtime Error

Solution code:
import math
 
N,K=map(int,input().split())
A=list(map(int,input().split()))
 
for i in range(K):
  ans=[0]*N
  for j in range(N):
    num=A[j]
    for k in range(max([j-num,0]),min([j+num+1,N])):
      ans[k]+=1
    #print(ans,max([j-num,0]),min([j+num,N-1]))
  A=ans
  
  if np.all(ans == N):
    break
print(' '.join(map(str, ans)))

Submission status: Runtime Error

Solution code:
from itertools import accumulate
from math import log2

n, k = map(int, input().split())
a = list(map(int, input().split()))

for j in range(k):
    a01 = [0] * (n + 1)
    for i, ai in enumerate(a):
        l, r = max(0, i - ai), min(i + ai + 1, n)
        a01[l] += 1
        a01[r] -= 1
    a = list(accumulate(a01))
    if all(ai == n for ai in ai[:-1]):
        break
print(*a[:-1])

Submission status: Runtime Error

Solution code:
N,K,*A = map(int, open(0).read().split())

def left(i, d):
    if not (0 <= i < N):
        return 0
    v = A[i] - d + 0.5
    if v <= 0:
        return 0 + left(i - 1, d + 1)
    else:
        return 1 + left(i - 1, d + 1)

def right(i, d):
    if not (0 <= i < N):
        return 0
    v = A[i] - d + 0.5
    if v <= 0:
        return 0 + right(i + 1, d + 1)
    else:
        return 1 + right(i + 1, d + 1)

for _ in range(K):
    X = [0 for _ in range(N)]
    for i in range(N):
        l = left(i-1, 1)
        r = right(i+1, 1)
        c = 1 + l + r
        X[i] = c
    if A == X:
        print(" ".join(map(str, A)))
        exit(0)
    A = X

print(" ".join(map(str, A)))

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import jit
@jit
def main():
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    A=np.array(a)
    l,r=0,0
    for i in range(min(41,k)):
        B=np.zeros(n+1,dtype=np.int64)
        for x,y in enumerate(list(A)):
            l=max(0,x-y)
            r=min(n,x+y+1)
            B[l]+=1
            B[r]-=1
        A=np.cumsum(B[:-1])
    print(*A,sep=' ')

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import numpy as np


def c(A):
    N = len(A)
    B = np.zeros_like(A)
    for i, a in enumerate(A):
        l = max(0, i - x)
        r = min(N - 1, i + x)
        B[l] += 1
        if r + 1 < N:
            B[r + 1] -= 1

    B = np.cumsum(B)
    return B


N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))


K = min(K, 50)
for _ in range(K):
    A = update(A)

print(' '.join(A.astype(str)))

Submission status: Runtime Error

Solution code:
import numpy as np

N, K = map(int,input().split())
A = list(map(int, input().split()))

_result = np.array([0]*N)

for _ in range(K):
    result = _result.copy()
    
    for i in l_n:
        _idx_st = i - A[i]
        idx_st = 0 if _idx_st < 0 else _idx_st
        _idx_end = i + A[i]
        idx_end = N if _idx_end >= N else _idx_end + 1

        result[idx_st:idx_end]+=1
        if np.all(result == N):
            break
            
    if np.all(result == N):
        break

    A = result.copy()
    
print(*result)

Submission status: Runtime Error

Solution code:
import sys
import copy
from numba import njit

def I(): return int(sys.stdin.readline().rstrip())
def LI():return list(map(int,sys.stdin.readline().rstrip().split()))
def LS():return list(sys.stdin.readline().rstrip().split())

@njit(parallel=True)
def main(N,K,A):
    #print(N,K)
    #print(A)

    for k in range(K):
        B = [0]*N
        for i, a in enumerate(A):
            #print(i, a)
            if a == 0:
                B[i] += 1
            else:
                # i-(a+0.5) ~ i+(a+0.5)
                # i: 整数、a: ＋整数　なので +0.5 は切り捨てられる。
                #　影響範囲は、 i-a ~ i+a
                for p in range(i-a,i+a+1):
                    #print("p:",p)
                    if p >=0 and p < N:
                        B[p] += 1
                #print(B)
        if k < K-1:
            A = B
        else:
            return B




if __name__ == '__main__':
    N,K = LI()[:]
    A = LI()
    B = main(N,K,A)
    print(B)

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))

def r(i,a):
    x1=i+1-a
    x2=i+2+a
    return [l for l in range(x1,x2) if(l>0 and l-1<N)]

for k in range(K):
    if(A=[0]*N):
        break
    B=[0]*N
    for i in range(N):
        for m in r(i,A[i]):
            B[m-1]+=1
    A=B
print(' '.join(map(str, A)))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

def solve():
    N, K = map(int, input().split())
    A = np.array(list(map(int, input().split()))).reshape(N,1)
    M = np.arange(N, dtype=np.int32).reshape(N,1)
    MT = np.arange(N, dtype=np.int32).reshape(1,N)
    for _ in range(K):
        if (A==N).all(): break
        A = (((M-A)<=MT) & (MT<(M+A+1))).sum(axis=0,keepdims=1).T
    return ' '.join(map(str,A.flatten()))

if __name__ == '__main__':
    print(solve())

Submission status: Runtime Error

Solution code:
import math

n,k=(int(x) for x in input().split())
a = [int(x) for x in input().split()]

for x in range(min(k,math.log(n, 10))):
    new_a = [0]*n
    for j,l in enumerate(a):
        for i in range(-l,l+1):
            if j+i >= 0 and j+i<n:
                new_a[j+i]+=1
    a = new_a

print(" ".join([str(x) for x in a]))

Submission status: Runtime Error

Solution code:
import numpy as np

if __name__ == '__main__':
    N, K = map(int, input().strip().split(" "))
    A = np.array(input().strip().split(" ")).astype(int)

    if K >= 41:
        print(" ".join([str(N)] * N))
    else:
        B = np.zeros(N)
        for i in range(K):
            for j in range(N):
                for k in range(max(0, j - A[j]), min(j + A[j] + 1, N), 1):
                    N[k] = True
            A = B.copy()
        print(" ".join(A.astype(str)))

Submission status: Runtime Error

Solution code:
import numpy as np

if __name__ == '__main__':
    N, K = map(int, input().strip().split(" "))
    A = np.array(input().strip().split(" ")).astype(int)

    if K >= 41:
        print(" ".join([str(N)] * N))
    else:
        B = np.identity(N).astype(bool)
        for i in range(K):
            for j in range(N):
                for k in range(max(0, j - A[j]), min(j + A[j] + 1, N), 1):
                    B[j][k] = True
            A = np.sum(B, axis=0)
        print(" ".join(A.astype(str)))

Submission status: Runtime Error

Solution code:
import numpy as np

if __name__ == '__main__':
    N, K = map(int, input().strip().split(" "))
    A = np.array(input().strip().split(" ")).astype(int)

    if K <= 41:
        print(" ".join([str(N)] * N))
    else:
        B = np.identity(N).astype(bool)
        for i in range(K):
            for j in range(N):
                for k in range(max(0, j - A[j]), min(j + A[j] + 1, N), 1):
                    B[j][k] = True
            A = np.sum(B, axis=0)
        print(" ".join(A.astype(str)))

Submission status: Runtime Error

Solution code:
def main():
    n, K = map(int, input().split())
    a = list(map(int, input().split()))
    cnt = a.count(n)
    for k in range(min(k, 100)):
        an = [0] * n
        for i in range(n):
            if an[i] < n:
                an[i] += 1
            for j in range(1, a[i]+1):
                if i - j >= 0 and an[i-j] < n:
                    an[i-j] += 1
                    if an[i-j] == n:
                        cnt += 1
                if i + j < n and an[i+j] < n:
                    an[i+j] += 1
                    if an[i+j] == n:
                        cnt += 1
        else:
            a = an
            if cnt == n:
                break
    print(*a)
main()

Submission status: Runtime Error

Solution code:
import math
import copy

light_count = 1


def init():
    game_info = input().split(" ")
    light_list = {}

    global light_count
    light_count = int(game_info[0])
    act_count = int(game_info[1])

    for index, value in enumerate(input().split(" ")):
        light_list[index + 1] = int(value)

    return act_count, light_list


def check_min(key, value):
    if math.ceil(key - value - 0.5) < 1:
        return 1

    else:
        return math.ceil(key - value - 0.5)


def check_max(key, value, light_count):
    if math.floor(key + value + 0.5) > light_count:
        return light_count

    else:
        return math.floor(key + value + 0.5)


def execute_action(light_list, remain_count):

    result = {}

    for key, value in light_list.items():
        min = check_min(key, value)
        max = check_max(key, value, light_count)

        for x in range(min, max + 1):
            if x in result:
                result[x] = result[x] + 1
            else:
                result[x] = 1

    return result


def main():
    act_count, light_list = init()

    for i in range(act_count):
        if all([value == light_count for value in light_list.values()]):
            result_list = [str(light_count)] * light_count
            print(' '.join(result_list))
        else:
            result = execute_action(light_list, act_count - i)
            light_list = copy.deepcopy(result)

    print(' '.join([str(i) for i in result.values()]))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import numpy as np
# import sys
# import copy
# def input(): return sys.stdin.readline().rstrip()
# input = sys.stdin.readline
# input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10 ** 7)

N, K = map(int, input().split())
A = np.array(list(map(int, (input().split()))))
# A = list(map(int, (input().split())))
nd = np.zeros((N,N), dtype=bool)
# print(*A)
for i in range(K):
    # cnt = [0]*N
    for j in range(N):
        nd[j, max(j-A[j],0):min(j+A[j]+1,N)] = True
        # for k in range(max(j-A[j],0), min(j+A[j]+1,N)):
        #     cnt[k] += 1
    # print(nd)
    A = np.count_nonzero(nd, axis=0)
    if A[0] == A[N-1] == N:
        break
    # A = copy.copy(cnt)
    # print(*A)

print(*A)

Submission status: Runtime Error

Solution code:
import copy

def blight(dist,_i):
	l=_i-dist
	r=_i+dist+1
	if l<0:l=0
	if r>n:r=n
	for _ in range(l,r):
		b[_]+=1

n,k=map(int,input().split())
a=list(map(int,input().split()))

cnt=0
cntmax=1000
while cnt<k:
	if k>cntmax:
		break

	b=[0]*n
	for i in range(n):
		blight(a[i],i)
	cnt+=1
	a=copy.deepcopy(b)
	print(b)
print(" ".join(map(str,b)))

Submission status: Runtime Error

Solution code:
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
import numpy as np

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,k=map(int, readline().rstrip().split())
    arr=list(map(int, readline().rstrip().split()))
    for _ in range(k):
        tmp=[0]*n
        for i in range(n):
            x = i - arr[i]
            y = i + arr[i] + 1
            if x<0:
                x=0
            if y<n:
                tmp[y]-=1
            tmp[x]+=1
        sm=tmp[0]
        arr[0]=tmp[0]
        for i in range(1,n):
            arr[i]=arr[i-1]+tmp[i]
            sm+=abs(tmp[i])
        if tmp[0]==n and sm==n:
            break
    print(" ".join(map(str,arr)))
    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Submission status: Runtime Error

Solution code:
import math
import numpy as np
N,K=map(int,input().split())
a=[0]*N
a=list(map(int,input().split()))
A=np.array(a)
b=np.zeros(N)
for i in range(K):
    if(K*N==np.sum(A)):
        break
    b=np.zeros(N)
    for j in range(N):

        minmin=max(0,math.ceil(j-A[j]-0.5))

        maxmax=min(N,math.floor(j+A[j]+0.5)+1)

        if(minmin==maxmax):
            maxmax=maxmax+1
            if(N<=maxmax):
                minmin=N-1
                maxmax=N

        for k in range(minmin,maxmax):
            b[k]=b[k]+1

    A=b
A=A.astype(np.int)
da=list(A)
L=[str(a) for a in da]

da=" ".join(L)
print(da)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import math
N, K = map(int, input().split())
A = input().split()
AK = [[0 for j in range(N)] for i in range(2)]
for l in range(N):
  AK[0][l] = int(AK[0][l]) + int(A[l])
p = int(math.log10(K+1))
for m in range(1,int(P),1):
  for o in range(N):
    for x in range(N):
      if((o-AK[0][o]+0.5) < (x+1)) and ((x+1) < (o+AK[0][o]+1.5)):
        AK[1][x] = AK[1][x] +1
  AK[0] = AK[1]
  AK[1] = [0] * N
print(*AK[0])

Submission status: Runtime Error

Solution code:
from math import log2

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    if K > log2(N):
        return print(*[N]*N,sep = " ")
    for _ in range(K):
        imos = [0]*(N + 1)
        for i in range(N):
            imos[max(0,i  - A[i])] += 1
            imos[min(N,i + 1 + A[i])] -= 1
        for j in range(N):
            imos[j+1] += imos[j]
            flag += 1 if imos[j] == N else 0
        A = imos[:N].copy()
    print(*A,sep=" ")
    return 

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    for i in range(min(K,100)):
        dm = [0]*N
        for x in range(N):
            dm[max(x - A[x],0)]+=1
            if x+A[i]+1<N:
                dm[x+A[x]+1]+=-1
        for j in range(1,N):
            dm[j]=dm[j-1]+dm[j]
        A[:] = dm[:]
    print(*A)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import numpy as np
import math
N, K = list(map(int, input().split()))
lamps = np.array(list(map(int, input().split())))

init = lamps
for i in range(K):
    act = np.zeros((N, N))
    for i in range(N):
        if init[i] == 0:
            continue
        d = math.floor(init[i] + 0.5)
        dmin = i - d
        dmax = i + d
        if dmin < 0:
            dmin = 0
        if dmax > N-1:
            dmax = N-1
        act[i][dmin:dmax+1] = 1
        act[i][i] = 0
    s = np.sum(act, axis=0)
    init = s + np.ones(N)
result = init.astype("int64")
ans = list(map(str,result.tolist()))
print(" ".join(ans))

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
import numpy as np


def nextL(A, D):
    L = D
    i = 1
    for a in A:
        line = np.ones(a*2+1)
        L[i-1, n+i-a:n+i+a+1] = line
        i+=1
    L = L[:, n+1:2*n+1]
    Na = np.sum(L, axis=0)
    return Na


n, k = map(int, input().split())
A = [int(a) for a in input().split()]

D = np.zeros((n, 3*n+2))

if k >= 50:
    print((str(n)+" ")*n)
else:
    for i in range(k):
        Na = nextL(A, D)
        A = Na
    Li=[str(int(a)) for a in A]
    Li=" ".join(Li)
    print(Li)

Submission status: Runtime Error

Solution code:
N,K,*A = map(int, open(0).read().split())

def left(i, d):
    if not (0 <= i < N):
        return 0
    v = A[i] - d + 0.5
    if v <= 0:
        return 0
    else:
        return 1 + left(i - 1, d + 1)

def right(i, d):
    if not (0 <= i < N):
        return 0
    v = A[i] - d + 0.5
    if v <= 0:
        return 0
    else:
        return 1 + right(i + 1, d + 1)

for _ in range(K):
    X = [0 for _ in range(N)]
    for i, d in enumerate(A):
        l = left(i-1, 1)
        r = right(i+1, 1)
        c = 1 + l + r
        X[i] = c
    A = X
    if all([N == a for a in A]):
        print(" ".join(map(str, A)))
        exit(0)

print(" ".join(map(str, A)))

Submission status: Runtime Error

Solution code:
import numpy as np
import sys
# import copy
# def input(): return sys.stdin.readline().rstrip()
# input = sys.stdin.readline
input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10 ** 7)

N, K = map(int, input().split())
A = np.array(list(map(int, (input().split()))))
# A = list(map(int, (input().split())))
nd = np.zeros((N,N), dtype=bool)
# print(*A)
for i in range(K):
    # cnt = [0]*N
    for j in range(N):
        nd[j, max(j-A[j],0):min(j+A[j]+1,N)] = True
        # for k in range(max(j-A[j],0), min(j+A[j]+1,N)):
        #     cnt[k] += 1
    # print(nd)
    A = np.count_nonzero(nd, axis=0)
    if A[0] == A[N-1] == N:
        break
    # A = copy.copy(cnt)
    # print(*A)

print(*A)

Submission status: Runtime Error

Solution code:
import numpy as np
import math
N, K = list(map(int, input().split()))
lamps = np.array(list(map(int, input().split())))

init = lamps
for i in range(K):
    act = np.zeros((N, N))
    for i in range(N):
        if init[i] == 0:
            continue
        d = math.floor(init[i] + 0.5)
        dmin = i - d
        dmax = i + d
        if dmin < 0:
            dmin = 0
        if dmax > N-1:
            dmax = N-1
        act[i][dmin:dmax+1] = 1
        act[i][i] -= 1
    s = np.sum(act, axis=0)
    init = s + np.ones(N)
result = init.astype("int64")
ans = list(map(str,result.tolist()))
print(" ".join(ans))

Submission status: Runtime Error

Solution code:
import math

N,K=map(int,input().split())
a=[0]*N
a=list(map(int,input().split()))
A=np.array(a)
b=np.zeros(N)
for i in range(K):
    if(K*N==sum(A)):
        break
    b=np.zeros(N)
    for j in range(N):

        minmin=max(0,math.ceil(j-A[j]-0.5))

        maxmax=min(N,math.floor(j+A[j]+0.5)+1)

        if(minmin==maxmax):
            maxmax=maxmax+1
            if(N<=maxmax):
                minmin=N-1
                maxmax=N

        for k in range(minmin,maxmax):
            b[k]=b[k]+1

    A=b
A=A.astype(np.int)
da=list(A)
L=[str(a) for a in da]

da=" ".join(L)
print(da)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
A = input().split()
AK = [[0 for j in range(N)] for i in range(2)]
for l in range(N):
  AK[0][l] = int(AK[0][l]) + int(A[l])

for m in range(1,math.log(K+1),1):
  for o in range(N):
    for x in range(N):
      if((o-AK[0][o]+0.5) < (x+1)) and ((x+1) < (o+AK[0][o]+1.5)):
        AK[1][x] = AK[1][x] +1
  AK[0] = AK[1]
  AK[1] = [0] * N
print(*AK[0])

Submission status: Runtime Error

Solution code:
import math
import numpy as np
N,K=map(int,input().split())
a=[0]*N
a=list(map(int,input().split()))
A=np.array(a)
b=np.zeros(N)
for i in range(K):
    if(K*N==sum(A)):
        break
    b=np.zeros(N)
    for j in range(N):

        minmin=max(0,math.ceil(j-A[j]-0.5))

        maxmax=min(N,math.floor(j+A[j]+0.5)+1)

        if(minmin==maxmax):
            maxmax=maxmax+1
            if(N<=maxmax):
                minmin=N-1
                maxmax=N

        for k in range(minmin,maxmax):
            b[k]=b[k]+1

    A=b
A=A.astype(np.int)
da=list(A)
L=[str(a) for a in da]

da=" ".join(L)
print(da)

Submission status: Runtime Error

Solution code:
import numpy as np


def read_input(trans=int):
    return list(map(trans, input().split()))


N, K = read_input()
A = np.array(read_input(), dtype="int")
B = np.zeros(N, dtype="int")
coordinate = np.arange(1, N+1)

limit = np.log(N)
for j in range(K):
    for i in range(N):
        c = coordinate[i]
        B[i] = (A >= np.abs(coordinate - c)).sum()
    A = B.copy()
    if j > limit_count:
        break


print(" ".join(map(str, A.tolist())))

Submission status: Runtime Error

Solution code:
N,K=list(map(int,input().split(' ')))
A=list(map(int,input().split(' ')))
A2=A
S=[]
if K>=N//5+5:
    l=list(map(str,[N]*N))
    print(" ".join(l))
    exit()
for i in range(K):
    A=A2
    A2=[0]*N
    for i in range(len(A)):
        d=A[i]
        for j in range(d+1):
            if i-j>=0 and j>0:
                A2[i-j]=A2[i-j]+1
            if i+j<N:
                A2[i+j]=A2[i+j]+1
    if [N]*N==A2:
    l=list(map(str,[N]*N))
    print(" ".join(l))
    exit()

print(" ".join(map(str,A2)))

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
import copy
input=sys.stdin.readline
def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    lighted = np.array([0]*N)
    for i,a in enumerate(A):
        area = len(lighted[max(0,i-a):min(i+a,N-1)+1])
        lighted[max(0,i-a):min(i+a,N-1)+1] += np.array([1]*area)
    print(*A)
    print(lighted)
    
    for _ in range(K-1):
        tmp = np.array([0]*N)
        for i,a in enumerate(lighted):
            area = len(tmp[max(0,i-a):min(i+a,N-1)+1])
            tmp[max(0,i-a):min(i+a,N-1)+1] += np.array([1]*area)
        lighted = copy.deepcopy(tmp)
        if lighted[0] == N:
            break
        print(lighted)
    print(lighted)
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
import numpy as np

def nextLights(A, Defl):
    Lights = Defl
    i = 1
    for a in A:
        line = np.ones(a*2+1, dtype = int)
        Lights[i-1, n+i-a:n+i+a+1] = line
        i+=1
    Lights = Lights[:, n+1:2*n+1]
    Next_A = np.sum(Lights, axis=0)
    return Next_A

n, k = map(int, input().split())
A = [int(a) for a in input().split()]

Defl = np.zeros((n, 3*n+2), dtype = int)

if k >= n+1:
    print((str(n)+" ")*n)
else:
    for i in range(k):
        Next_A = nextLights(A, Defl)
        A = Next_A
    L=[str(a) for a in A]
    L=" ".join(L)
    print(L)

Submission status: Runtime Error

Solution code:
from itertools import accumulate

def mi():
    return map(int, input().split())

def main():
    N, K = mi()
    A = list(mi())

    for _ in range(K):
        l = [0]*N
        for i in range(N):
            left = max(i-A[i], 0)
            right = min(i+A[i]+1, N)
            l[left] += 1
            if right < N:
                l[right] -= 1
        if A != list(accumulate(l)):
            A = accumulate(l)
        else:
            break
    print(' '.join(list(map(str, A))))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import copy as cp
n,k = map(int,input().split())
lamps = list(map(int,input().split()))
for j in range(k):
    lamplog = [0]*n
    lamp_io = [0]*n
    for i in range(len(lamps)):
        if(i == 0):
            lamplog[i]=[0,lamps[i]]
        elif(i == n-1):
            lamplog[i]=[n-(lamps[i]+1) ,n-1]
        else:
            lamplog[i]= [max(i-lamps[i],0),min(i+lamps[i],n-1)]
    for i in range(len(lamplog)):
        for l in range(lamplog[i][1]-lamplog[i][0]+1):
            lamp_io[lamplog[i][0]+l]+=1
    # print(lamplog)
    lamps = cp.copy(lamp_io)
ans = ""
for i in range(len(lamp_io)):
    ans += str(lamps[i]) +" "
print(ans.rstrip())

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int,input().split()))
count_list = [0] * N
#print(count_list)
for i in range(N):
  Plus = i + A[i]
  Minus = i - A[i]
  if Plus >= N + 1:
    Plus = N 
  else:
    pass
  if Minus >= 0:
    Minus = 0
  else:
    pass
  A = Plus - Minus
  A_list = [1] * A
  count_list = list(map(lambda a,b: count_list[Minus:Plus] + A_list, count_list[Minus:Plus],A_list))
print(count_list)

Submission status: Runtime Error

Solution code:
def conv(A,N):
    #A(座標iの電灯の強さリスト)からB(座標iを照らしている電灯数)への変換
    B=[0 for n in range(N)]
    for n in range(1,N+1):
        il_min=max(int(n-A[n-1]-0.5)+1,0)
        il_max=min(int(n+A[n-1]+0.5),N)
        B_=[B[i]+1 for i in range(N) if il_min<=i<=il_max]
    return B_

def main():
    #input
    N,K=map(int,input().strip().split())
    A=list(map(int,input().strip().split()))

    if K>30:
        A=[N for n in range(N)]
        A[-1]=2*N
    else:
        for k in range(K):
            B=conv(A,N)
            if A==B:
                break
            else:
                A=B
    return " ".join(list(map(str,A)))

if __name__=="__main__":
    print(main())

Submission status: Runtime Error

Solution code:
N, K = map(int,input().split())

l = list(map(int,input().split()))

ans = [0]*N

def mainasu(n):
    return n-1

import copy

for k in range(K):
    for j in range(N):
        zahyo = j + 1
        for q in range(l[j]*2+1):
            count = zahyo - l[j] -1 + q
            if int(len(l))-1 >= count >= 0 :
                ans[count] += 1
    if k != 0 :
        for p in range(N):
            ans[p] -= l[p]
    l = copy.copy(ans)

print(''.join(ans))

Submission status: Runtime Error

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    dm = [0]*N
    dm[:] = A[:]

    for i in range(K):
        dm_ = [0]*N
        for x in range(N):
            dm_[max(x - dm[x],0)]+=1
            if x+dm[i]+1<N:
                dm_[x + dm[x] + 1]+=-1
        dm[:] = dm_[:]

#            print(dm)
        for j in range(1,N):
            dm[j]=dm[j-1]+dm[j]
    print(*dm)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import copy as cp
n,k = map(int,input().split())
lamps = list(map(int,input().split()))
for j in range(k):
    lamplog = [0]*n
    lamp_io = [0]*n
    for i in range(len(lamps)):
        if(i == 0):
            lamplog[i]=[0,lamps[i]]
        elif(i == n-1):
            lamplog[i]=[n-(lamps[i]+1) ,n-1]
        else:
            lamplog[i]= [max(i-lamps[i],0),min(i+lamps[i],n-1)]
    for i in range(len(lamplog)):
        for l in range(lamplog[i][1]-lamplog[i][0]+1):
            lamp_io[lamplog[i][0]+l]+=1
    # print(lamplog)
    lamps = cp.copy(lamp_io)
ans = ""
for i in range(len(lamp_io)):
    ans += str(lamp_io[i]) +" "
print(ans.rstrip())

Submission status: Runtime Error

Solution code:
N ,K = map(int,input().split())
A = list(map(int,input().split()))

a = [0]*(N+3)
for n in range(K):
  a = [0]*(N+2)
  for i in range(1,N+1):

    if A[i-1] == 0:
      a[i] += 1
    elif not A[i-1] == 0:
      s = A[i-1]
      a[i] += 1
      for m in range(s):
        h = i+1+m
        g = i-1+m
        
        if h>N:
          h = N+1
        if g<0:
          g = N+1
        a[h] += 1
        a[g] += 1
  A[0:5] = a[1:6]

print(a[1:6])

Submission status: Runtime Error

Solution code:
import copy
N,K = map(int,input().split())
while True:
    try:
        listA=list(map(int,input().split()))
    except:
        break;
        
for iter in range(K):
  lit_list=[0]*N
  for i in range(N):
    for j in range(N):
      for k in range(j+1):
        if 0<=i-k and i+k<=N+1:
          lit_list[i+k]+=1
          lit_list[i-k]+=1
          if k==0:
            lit_list[i-k]-=1
            
  listA=copy.deepcopy(lit_list)

print(' '.join(map(str, listA)))

Submission status: Runtime Error

Solution code:

n,k=map(int,input().split())
a=list(map(int,input().split()))

left=[0 for i in range(n)]
right=[0 for i in range(n)]
cntleft=0
cntright=0
sl=[0 for i in range(n)]
rl=[0 for i in range(n)]
for i in range(1,n):
    sl[i]+=a[i-k]+sl[i-1]
v=a[::-1]
for i in range(1,n):
    rl[i]+=v[i-k]+rl[i-1]

rl=rl[::-1]
for i in range(n):
    left[i]=sl[i]+rl[i]
print(*left)