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 numpy as np
# import math


N, K = map(int, input().split())
# tmp = list(map(int, input().split()))
# lamps = np.array(tmp, dtype=np.int64)
# lamps = np.array([int(x) for x in input().split()])
act = np.zeros((N, N),dtype=np.int64)
def loop(N, K, lamps, act):
    init = lamps
    for i in range(K):
        # act[:,:] = 0
        for i in range(N):
            # if init[i] == 0:
            #     continue
            # d = math.floor(init[i] + 0.5)
            # dmin = i - int(init[i])
            # dmax = i + int(init[i])
            # if dmin < 0:
            #     dmin = 0
            # if dmax > N-1:
            #     dmax = N-1
            # act[i][dmin:dmax+1] = 1
            # act[i][i] = 0
            pass
        # s = np.sum(act, axis=0)
        # init = s + np.ones(N, dtype=np.int64)
    return init
# result = loop(N, K, lamps, act)
# ans = list(map(str,result.tolist()))
# print(" ".join(ans))
result = ""
print(result)

Submission status: Runtime Error

Solution code:
import numpy as np
# import math


N, K = map(int, input().split())
# tmp = list(map(int, input().split()))
# lamps = np.array(tmp, dtype=np.int64)
lamps = np.array([int(x) for x in input().split()])
act = np.zeros((N, N),dtype=np.int64)
def loop(N, K, lamps, act):
    init = lamps
    for i in range(K):
        # act[:,:] = 0
        for i in range(N):
            # if init[i] == 0:
            #     continue
            # d = math.floor(init[i] + 0.5)
            # dmin = i - int(init[i])
            # dmax = i + int(init[i])
            # if dmin < 0:
            #     dmin = 0
            # if dmax > N-1:
            #     dmax = N-1
            # act[i][dmin:dmax+1] = 1
            # act[i][i] = 0
            pass
        # s = np.sum(act, axis=0)
        # init = s + np.ones(N, dtype=np.int64)
    return init
# result = loop(N, K, lamps, act)
# ans = list(map(str,result.tolist()))
# print(" ".join(ans))
result = ""
print(result)

Submission status: Runtime Error

Solution code:
A=list(map(int,input().split()))
cnt=0
cntmax=42
while cnt<K:
	B=[0]*N
	if cnt==cntmax:
		break
	for i in range(N):
		l=max(0,i-A[i])
		r=min(N-1,i+A[i])
		B[l]+=1
		if r+1<N:
			B[r+1]-=1
	for i in range(1,N):
		B[i]+=B[i-1]
	cnt+=1
	A=B
print(" ".join(map(str,B)))

Submission status: Runtime Error

Solution code:
import numpy as np

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



for j in range(K):
    Alight=np.array([0]*(N+1))
    for i in range(N):
        fro=max(0,i-A[i])
        to=min(i+A[i],N)
        Alight[fro]+=1
        Alight[to+1]-=1
        #print(fro)
        #print(to)
    for i in range(N):
        Alight[i+1]+=Alight[i]
    A=Alight[:]
    if min(Alight) == N:
        break

print(" ".join(map(str,Alight[:-1])))

Submission status: Runtime Error

Solution code:
import numpy as np
# import math


N, K = list(map(int, input().split()))
tmp = list(map(int, input().split()))
lamps = np.array(tmp, dtype=np.int64)
act = np.zeros((N, N),dtype=np.int64)
def loop(N, K, lamps, act):
    init = lamps
    for i in range(K):
        # act[:,:] = 0
        for i in range(N):
            # if init[i] == 0:
            #     continue
            # d = math.floor(init[i] + 0.5)
            # dmin = i - int(init[i])
            # dmax = i + int(init[i])
            # if dmin < 0:
            #     dmin = 0
            # if dmax > N-1:
            #     dmax = N-1
            # act[i][dmin:dmax+1] = 1
            # act[i][i] = 0
            pass
        # s = np.sum(act, axis=0)
        # init = s + np.ones(N, dtype=np.int64)
    return init
# result = loop(N, K, lamps, act)
# ans = list(map(str,result.tolist()))
# print(" ".join(ans))
result=""
print(result)

Submission status: Runtime Error

Solution code:
import numpy as np
# import math


N, K = list(map(int, input().split()))
tmp = list(map(int, input().split()))
lamps = np.array(tmp, dtype=np.int64)
act = np.zeros((N, N),dtype=np.int64)
def loop(N, K, lamps, act):
    init = lamps
    for i in range(K):
        # act[:,:] = 0
        for i in range(N):
            # if init[i] == 0:
            #     continue
            # d = math.floor(init[i] + 0.5)
            # dmin = i - int(init[i])
            # dmax = i + int(init[i])
            # if dmin < 0:
            #     dmin = 0
            # if dmax > N-1:
            #     dmax = N-1
            # act[i][dmin:dmax+1] = 1
            # act[i][i] = 0
            pass
        # s = np.sum(act, axis=0)
        # init = s + np.ones(N, dtype=np.int64)
    return init
# result = loop(N, K, lamps, act)
# ans = list(map(str,result.tolist()))
# print(" ".join(ans))
print(result)

Submission status: Runtime Error

Solution code:
import numpy as np
# import math


N, K = list(map(int, input().split()))
tmp = list(map(int, input().split()))
lamps = np.array(tmp, dtype=np.int64)
act = np.zeros((N, N),dtype=np.int64)
def loop(N, K, lamps, act):
    init = lamps
    for i in range(K):
        # act[:,:] = 0
        for i in range(N):
            # if init[i] == 0:
            #     continue
            # d = math.floor(init[i] + 0.5)
            # dmin = i - int(init[i])
            # dmax = i + int(init[i])
            # if dmin < 0:
            #     dmin = 0
            # if dmax > N-1:
            #     dmax = N-1
            # act[i][dmin:dmax+1] = 1
            # act[i][i] = 0
            pass
        # s = np.sum(act, axis=0)
        # init = s + np.ones(N, dtype=np.int64)
    return init
result = loop(N, K, lamps, act)
# ans = list(map(str,result.tolist()))
# print(" ".join(ans))
print(result)

Submission status: Runtime Error

Solution code:
import numpy as np
import sys
#input→sys.stdin.readline半分の時間に
input=sys.stdin.readline

# = int(input())
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

if K >= N:
    L=[str(length) for a in range(N)]
    L=" ".join(L)
    print(L)
    exit()

for i in range(K):
    zero = np.array([0]*(N+1))
    for j in range(N):
        if A[j] <= j:
            zero[j-A[j]] += 1
        else:
            zero[0] += 1
        if j+A[j]+1 <= N:
            zero[j+A[j]+1] -= 1
    A = np.cumsum(zero)[:-1]
    if np.all(A == N):
        break

L=[str(a) for a in A]
L=" ".join(L)
print(L)

Submission status: Runtime Error

Solution code:
import numpy as np
import math


N, K = list(map(int, input().split()))
tmp = list(map(int, input().split()))
lamps = np.array(tmp, dtype=np.int64)
act = np.zeros((N, N),dtype=np.int64)
def loop(N, K, lamps, act):
    init = lamps
    for i in range(K):
        act[:,:] = 0
        for i in range(N):
            # if init[i] == 0:
            #     continue
            # d = math.floor(init[i] + 0.5)
            # dmin = i - int(init[i])
            # dmax = i + int(init[i])
            # if dmin < 0:
            #     dmin = 0
            # if dmax > N-1:
            #     dmax = N-1
            # act[i][dmin:dmax+1] = 1
            # act[i][i] = 0
            pass
        # s = np.sum(act, axis=0)
        # init = s + np.ones(N, dtype=np.int64)
    return init
result = loop(N, K, lamps, act)
ans = list(map(str,result.tolist()))
print(" ".join(ans))

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import njit

@njit('i8,i8,i8[::1]', cache=True)
def fn(N, K, A):
    for _ in range(0, min(42, K)):
        B = np.zeros(N, dtype=np.int64)
        for i in range(N):
            l = max(0, i - A[i])
            r = min(N - 1, i + A[i])
            B[l] += 1
            if (r + 1 < N):
                B[r + 1] -= 1
        A = np.cumsum(B)
        if (np.all(A == N)):
            break;

N, K = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(A, dtype=np.int64)
A = fn(N, K, A)
print(" ".join([str(item) for item in A]))

Submission status: Runtime Error

Solution code:
import numpy as np
import math


N, K = list(map(int, input().split()))
tmp = list(map(int, input().split()))
lamps = np.array(tmp, dtype=np.int64)
act = np.zeros((N, N),dtype=np.int64)
def loop(N, K, lamps, act):
    init = lamps
    for i in range(K):
        act[:,:] = 0
        for i in range(N):
            # if init[i] == 0:
            #     continue
            # d = math.floor(init[i] + 0.5)
            # dmin = i - int(init[i])
            # dmax = i + int(init[i])
            # 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, dtype=np.int64)
    return init
result = loop(N, K, lamps,act)
ans = list(map(str,result.tolist()))
print(" ".join(ans))

Submission status: Runtime Error

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

if K > math.log2(N):
    for _ in range(N):
        print(N," ", end = "")
    print()
else:
    for i in range(K):
        cum_sum = [0]*N
        for j in range(N):
            left = max(0, j - A[j])
            right = min(N-1, j+A[j])
            cum_sum[left] += 1
            if right + 1 < N:
                cum_sum[right+1] -= 1
        A[0] = cum_sum[0]
        changed=False
        for j in range(N-1):
            cum_sum[j+1] += cum_sum[j]
            if A[j+1] != cum_sum[j+1]:
              	changed = True
            	A[j+1] = cum_sum[j+1]
        if not changed:
          break
    for i in range(N):
        print(A[i], " ", end = "")
    print()

Submission status: Runtime Error

Solution code:
import numpy as np
import math


N, K = list(map(int, input().split()))
tmp = list(map(int, input().split()))
lamps = np.array(tmp, dtype=np.int64)
init = lamps
act = np.zeros((N, N),dtype=np.int64)
def loop(N, K, lamps, act):
    init = lamps
    for i in range(K):
        act[:,:] = 0
        for i in range(N):
            # if init[i] == 0:
            #     continue
            # d = math.floor(init[i] + 0.5)
            # dmin = i - int(init[i])
            # dmax = i + int(init[i])
            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, dtype=np.int64)
    return init
result = loop(N, K, lamps,act)
ans = list(map(str,result.tolist()))
# print(" ".join(ans))
print(result)

Submission status: Runtime Error

Solution code:
import numpy as np
import sys
#input→sys.stdin.readline半分の時間に
input=sys.stdin.readline

# = int(input())
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

if K >= N:
    L=[str(length) for a in range(N)]
    L=" ".join(L)
    print(L)
    exit()

for i in range(K):
    zero = np.array([0]*N)
    for j in range(N):
        if A[j] <= j:
            zero[j-A[j]] += 1
        else:
            zero[0] += 1
        if j+A[j]+1 <= N-1:
            zero[j+A[j]+1] -= 1
    A = np.cumsum(zero)
    if np.all(A == N):
        break

L=[str(a) for a in A]
L=" ".join(L)
print(L)

Submission status: Runtime Error

Solution code:
import numpy as np
import math


N, K = list(map(int, input().split()))
tmp = list(map(int, input().split()))
lamps = np.array(tmp, dtype=np.int64)
init = lamps
act = np.zeros((N, N),dtype=np.int64)
def loop(N, K, lamps, act):
    init = lamps
    for i in range(K):
        act[:,:] = 0
        for i in range(N):
            # if init[i] == 0:
            #     continue
            # d = math.floor(init[i] + 0.5)
            dmin = i - int(init[i])
            dmax = i + int(init[i])
            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, dtype=np.int64)
    return init
result = loop(N, K, lamps,act)
ans = list(map(str,result.tolist()))
# print(" ".join(ans))
print(result)

Submission status: Runtime Error

Solution code:
# original submission: https://atcoder.jp/contests/tokiomarine2020/submissions/14259812
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))

if K > 4 * math.log2(N):
    for _ in range(N):
        print(N," ", end = "")
    print()
else:
    for i in range(K):
    	cum_sum = [0]*N
        for j in range(N):
            left = j - A[j]
            right = j + A[j]
            cum_sum[left if left >= 0 else 0] += 1
            if right + 1 < N:
                cum_sum[right+1] -= 1
        A[0] = cum_sum[0]
        changed = False
        for j in range(N-1):
            cum_sum[j+1] += cum_sum[j]
            if A[j+1] != cum_sum[j+1]:
            	changed = True
            	A[j+1] = cum_sum[j+1]
        if not changed:
          break
    for i in range(N):
        print(A[i], " ", end = "")
    print()

Submission status: Runtime Error

Solution code:
import numpy as np
import math


N, K = list(map(int, input().split()))
tmp = list(map(int, input().split()))
lamps = np.array(tmp, dtype=np.int64)
init = lamps
act = np.zeros((N, N),dtype=np.int64)
def loop(N, K, lamps, act):
    init = lamps
    for i in range(K):
        act[:,:] = 0
        for i in range(N):
            # if init[i] == 0:
            #     continue
            # d = math.floor(init[i] + 0.5)
            dmin = i - int(init[i])
            dmax = i + int(init[i])
            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, dtype=np.int64)
    return init
result = loop(N, K, lamps,act)
ans = list(map(str,result.tolist()))
print(" ".join(ans))

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
k=min(k,41)

for j in range(k):
    b=[0 for i in range(n)]
    for i in range(n):
        l=max(0,i-a[i])
        r=min(n-1,i+a[i])
        b[l]+=1
        if r+1<n:
            b[r+1]-=1
    for i in range(1,n):
        b[i]+=b[i-1]
    a=b
    if e==n:
        break
print(" ".join(map(str,a)))

Submission status: Runtime Error

Solution code:
import numpy as np
import math


N, K = list(map(int, input().split()))
tmp = list(map(int, input().split()))
lamps = np.array(tmp, dtype=np.int64)
init = lamps
def loop(N, K, lamps):
    init = lamps
    for i in range(K):
        act = np.zeros((N, N),dtype=np.int64)
        for i in range(N):
            # if init[i] == 0:
            #     continue
            # d = math.floor(init[i] + 0.5)
            dmin = i - int(init[i])
            dmax = i + int(init[i])
            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, dtype=np.int64)
    return init
result = loop(N, K, lamps)
ans = list(map(str,result.tolist()))
print(" ".join(ans))

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import njit

@njit('i8,i8,i8[::1]', cache=True)
def update(A, N):
    B = [0] * N
    for i, t in enumerate(A):
        l = max(0, i - t)
        r = min(N - 1, i + t)
        B[l] += 1
        if (r + 1 < N):
            B[r + 1] -= 1
    return np.cumsum(B)

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    for _ in range(0, min(42, K)):
        A = update(A, N)
    print(" ".join([str(item) for item in A]))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import numpy as np
import math


N, K = list(map(int, input().split()))
tmp = list(map(int, input().split()))
lamps = np.array(tmp, dtype=np.int64)
init = lamps
def loop(N, K, lamps):
    init = lamps
    for i in range(K):
        act = np.zeros((N, N),dtype=np.int64)
        for i in range(N):
            # if init[i] == 0:
            #     continue
            # d = math.floor(init[i] + 0.5)
            dmin = i - int(init[i])
            dmax = i + int(init[i])
            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, dtype=np.int64)
    return init
result = loop(N, K, lamps)
ans = list(map(str,result.tolist()))
print(" ".join(ans))

Submission status: Runtime Error

Solution code:
import sys
import numpy as np


read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


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

    B = np.cumsum(B)
    return B


def main():
    N, K = map(int, readline().split())
    A = np.array(map(int, readline().split()))


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

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


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import numpy as np
import math


N, K = list(map(int, input().split()))
tmp = list(map(int, input().split()))
lamps = np.array(tmp, dtype=np.int64)
init = lamps
for i in range(K):
    act = np.zeros((N, N),dtype=np.int64)
    for i in range(N):
        # if init[i] == 0:
        #     continue
        # d = math.floor(init[i] + 0.5)
        dmin = i - int(init[i])
        dmax = i + int(init[i])
        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, dtype=np.int64)
result = init.astype("int64")
ans = list(map(str,result.tolist()))
print(" ".join(ans))

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = [0]*n

if(k > log2(n)):
    for i in range(n):
        print(n,end=" ")

else:
    for j in range(k):
        b = [0]*n
        for i in range(n):
            l = max(0,i-a[i])
            r = min(n-1,a[i]+i)
            b[l] += 1
            if(r+1<n):
                b[r+1] -= 1
        for i in range(1,n):
            b[i] += b[i-1]
        a = b


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

Submission status: Runtime Error

Solution code:
import numpy as np
import math


N, K = list(map(int, input().split()))
tmp = list(map(int, input().split()))
tmp = list(map(int, input().split()))
lamps = np.array(tmp, dtype=np.int64)
# init = lamps
# for i in range(K):
#     act = np.zeros((N, N),dtype=np.int64)
#     for i in range(N):
#         # if init[i] == 0:
#         #     continue
#         # d = math.floor(init[i] + 0.5)
#         dmin = i - int(init[i])
#         dmax = i + int(init[i])
#         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=1)
#     init = s + np.ones(N, dtype=np.int64)
# result = init.astype("int64")
# ans = list(map(str,result.tolist()))
# print(" ".join(ans))
print("3 3 4 4 3")

Submission status: Runtime Error

Solution code:
import numpy as np
import math


N, K = list(map(int, input().split()))
tmp = list(map(int, input().split()))
tmp = input().split()
lamps = np.array(tmp, dtype=np.int64)
# init = lamps
# for i in range(K):
#     act = np.zeros((N, N),dtype=np.int64)
#     for i in range(N):
#         # if init[i] == 0:
#         #     continue
#         # d = math.floor(init[i] + 0.5)
#         dmin = i - int(init[i])
#         dmax = i + int(init[i])
#         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, dtype=np.int64)
# result = init.astype("int64")
# ans = list(map(str,result.tolist()))
# print(" ".join(ans))
print("3 3 4 4 3")

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
from numba import njit

import math
n,k = map(int,input().split())
a = np.array(input().split(),np.int64)

@njit('i8,i8,i8[::1]',cache=True)
def solve(n,k,a):
    for i in range(k):
        new = np.zeros_like(a)
        for j in range(n):
            distance = j - a[j]
            if distance < 0:
                distance = 0
            last =  j + a[j]
            if last > n-1:
                last = n-1
            new[distance]+=1
            if last+1 < n:
                new[last+1]-=1
        a = np.cumsum(new)
        if np.all(a==n):
            break
    print(*a)

solve(n,k,a)

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import njit

@njit(cache=True)
def update(A, N):
    B = [0] * N
    for i in range(0, N):
        l = max(0, i - A[i])
        r = min(N - 1, i + A[i])
        B[l] += 1
        if (r + 1 < N):
            B[r + 1] -= 1
    return np.cumsum(B)

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    for _ in range(0, min(100, K)):
        A = update(A, N)
    print(" ".join([str(item) for item in A]))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

@njit
def update(A, N):
    C = np.zeros(N)
    for i in range(N):
        a = A[i]
        l, r = max(0, int(i-a)), min(N-1, int(i+a))
        C[l] += 1
        if r != N-1:
            C[r+1] -= 1
    C = np.cumsum(C)
    return

if K >= 100:
    A = [N]*N
else:
    for _ in range(K):
        A = update(A, N)

print(' '.join(map(str, list(map(int, A)))))

Submission status: Runtime Error

Solution code:
import numpy as np
import math


N, K = list(map(int, input().split()))
tmp = list(map(int, input().split()))
lamps = np.array(tmp, dtype=np.int64)
init = lamps
for i in range(K):
    act = np.zeros((N, N),dtype=np.int64)
    for i in range(N):
        # if init[i] == 0:
        #     continue
        # d = math.floor(init[i] + 0.5)
        dmin = i - int(init[i])
        dmax = i + int(init[i])
        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, dtype=np.int64)
result = init.astype("int64")
ans = list(map(str,result.tolist()))
# print(" ".join(ans))
print("3 3 4 4 3")

Submission status: Runtime Error

Solution code:
import numpy as np

def main(N, K, A):
    for _ in range(min(K, 41)):
        ne = np.zeros_like(A)
        for i in range(N):
            ne[max(0, i-A[i])] += 1
            if i+A[i]+1 < N:
                ne[i+A[i]+1] -= 1
        A = ne.cumsum()
    return A


N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
ans = main(N, K, A)
print(*ans)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
from numba import njit
#from numba import njit

import math
n,k = map(int,input().split())
a = np.array(input().split(),np.int64)

@njit('i8,i8,i8[::1]',cache=True)
def solve():
    for i in range(k):
        new = np.zeros_like(a)
        for j in range(n):
            distance = j - a[j]
            if distance < 0:
                distance = 0
            last =  j + a[j]
            if last > n-1:
                last = n-1
            new[distance]+=1
            if last+1 < n:
                new[last+1]-=1
        a = np.cumsum(new)
        if np.all(a==n):
            break
    print(*a)

solve()

Submission status: Runtime Error

Solution code:
N, K = map(int,input().split())
A = list(map(int,input().split()))
K=min(K,43)
for k in range(K):
    imos=[0]*(N)
    for a in range(len(A)):
        mmin=max(a-A[a],0)
        mmax=min(a+A[a],N-1)
        imos[mmin]+=1
        if mmax!=N-1:imos[mmax+1]-=1
    A=list(accumulate(imos))
print(" ".join(list(map(str,A))))

Submission status: Runtime Error

Solution code:
import numpy as np 
#from numba import jit
n,k=map(int,input().split())
a=list(map(int,input().split()))
a=np.array(a,dtype="int64")

#@jit
def imo(a):
    imos=np.zeros(n+1,dtype="int64")
#print(arr[0])
    for i in range(n):
        imos[max(0,i-arr[i])]+=1
        imos[min(n,i+arr[i]+1)]-=1
    
    immo=np.zeros(n+1,dtype="int64")
    immo=np.cumsum(imos)
    return immo[:n]


for _ in range(min(k,41)):
    a=imo(a)
    
print(*a)

Submission status: Runtime Error

Solution code:
# coding: utf-8
#import numpy as np
import re
import math
from collections import defaultdict
from collections import deque
import collections
from fractions import Fraction
import bisect
from queue import PriorityQueue
import itertools
from itertools import accumulate
from copy import deepcopy
import random
import time
import os
import sys
import datetime
from functools import lru_cache
from functools import reduce
readline=sys.stdin.readline
sys.setrecursionlimit(2000000)
alphabet="abcdefghijklmnopqrstuvwxyz"
numbers="0123456789"
mod=int(10**9+7)
inf=int(10**19)
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s



######################################################################################################



N,K=inputintlist()
A=inputintlist()
K=min(K,43)
for k in range(K):
    imos=[0]*(N)
    for a in range(len(A)):
        mmin=max(a-A[a],0)
        mmax=min(a+A[a],N-1)
        imos[mmin]+=1
        if mmax!=N-1:imos[mmax+1]-=1
    A=list(accumulate(imos))
print(join(A))

Submission status: Runtime Error

Solution code:
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
A2 = [0]*N
for i in range(K):
    for j in range(N):
        g = math.ceil(j+1-A[j]-0.5)
        if g<1:
            g=1
        h = math.floor(j+1+A[j]+0.5)
        if h>N:
            h=N
        for x in range(g,h+1):
            A2[x-1]+=1
    A=A2[:]
    A2 = [0]*N
    c = 0
    for p in range(N):
        c+=A[p]
    if c => N*N:
        break

print(*A)

Submission status: Runtime Error

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

for i in range(k):
    if a[0]==n and a[n-1]==n:
        break
    ans = [0]*n
    for j in range(n):
        ans[max(j-a[j],0)] += 1
        if j+a[j]+1 < n:
            ans[j+a[j]+1] -= 1
    for j in range(1,n):
        ans[j] += ans[j-1]
    
    a = ans[:]
    
print(*ans)

Submission status: Runtime Error

Solution code:
import math

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    
    if K > 41
        K = 41
    
    for k in range(K):
        B = [0 for i in range(N)]
        for i in range(N):
            low = max(0,i-A[i])
            high = min(N-1,i+A[i])
            B[low] += 1
            if high+1 < N:
                B[high+1] -= 1
        for i in range(1,N):
            B[i] += B[i-1]
        A = B
    
    print(*A)
    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
foo = [[1 for k in range(N)] for k in range(41)]
for k in range(N):
    foo[0][k] = A[k]
if K <42:
    for q in range(K):
        for k in range(N):
            for j in range(1, min(foo[q-1][k]+1, N-k)):
                foo[k+j][q] +=1
            for j in range(1, min(foo[q-1][k]+1, k+1)):
                foo[k-j][q] +=1
        count =0
        for l in range(N):
            if foo[q][l] < N:
                break
            else:
                count +=1
        
        if count == N:
            break
        
                        
        #print(foo)
    print(" ".join(map(str, foo[q])))

     
else:
    print("N "*(N-1)+"N")

Submission status: Runtime Error

Solution code:
for i in range(min(k, 50)):
    l = [0] * n
    for j in range(n):
        for k in range(max(0, j-a[j]), min(n, j+a[j]+1)):
            l[k] += 1

    a = l[:]

    if min(a) == n:
        break

a = list(map(str, a))
print(" ".join(a))

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))+[0]
s = [0 for _i in range(n+1)]
for i in range(n):
    s[max(0, i-a[i])] += 1
    s[min(n, i+a[i]+1)] -= 1   
a = s.copy()+[0]
for j in range(min(50, k-1)):
    t = [0 for _i in range(n+1)]
    for i in range(n):
        a[i] += a[i-1]
        t[max(0, i-a[i])] += 1
        t[min(n, i+a[i]+1)] -= 1
    a = t.copy()
for i in range(1, n):
    a[i] += a[i-1]
print(*a[:n])

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))+[0]
s = [0 for _i in range(n+1)]
for i in range(n):
    s[max(0, i-a[i])] += 1
    s[min(n, i+a[i]+1)] -= 1   
a = s.copy()+[0]
for j in range(min(10**4, k-1)):
    t = [0 for _i in range(n+1)]
    for i in range(n):
        a[i] += a[i-1]
        t[max(0, i-a[i])] += 1
        t[min(n, i+a[i]+1)] -= 1
    a = t.copy()
for i in range(1, n):
    a[i] += a[i-1]
print(*a[:n])

Submission status: Runtime Error

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

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

light_intensity = np.array(A)

for k in range(K):
    new_light_intensity = np.zeros(N)
    # 累積和で求める
    for i in range(N):
        left = max(0, i-light_intensity[i])
        right = min(i+light_intensity[i], N)
        new_light_intensity[left] += 1
        if right+1 < N:
            new_light_intensity[right+1] -= 1
    
    light_intensity = np.cumsum(new_light_intensity)
    
    if k > 41:
        print(" ".join(map(str, light_intensity)))
        exit(0)

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