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
from itertools import accumulate

N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

current_arr = A
if K > 41:
    print(" ".join([N]*N))
    sys.exit()
for _ in range(K):
    imos = [0] * N
    ruiseki = [0] * (N+1)
    for i, ai in enumerate(current_arr):
        imos[max([0, i-ai])] += 1
        if i+ai+1 < N:
            imos[i+ai+1] -= 1
    for j, im in enumerate(imos):
        ruiseki[j+1] = ruiseki[j] + im
    current_arr = ruiseki[1:]
#print(imos)
#print(ruiseki)
#print(*accumulate(imos))
print(*current_arr)

Submission status: Runtime Error

Solution code:
from itertools import accumulate

N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

current_arr = A
if K > 41:
    print(" ".join([N]*N))
    exit(0)
for _ in range(K):
    imos = [0] * N
    ruiseki = [0] * (N+1)
    for i, ai in enumerate(current_arr):
        imos[max([0, i-ai])] += 1
        if i+ai+1 < N:
            imos[i+ai+1] -= 1
    for j, im in enumerate(imos):
        ruiseki[j+1] = ruiseki[j] + im
    current_arr = ruiseki[1:]
#print(imos)
#print(ruiseki)
#print(*accumulate(imos))
print(*current_arr)

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import njit
 
n,k = map(int, input().split())
d = np.array(list(map(int, input().split())))
l = np.arange(n)
ans = np.array([0]*n)
cnt = 0


@njit('(i8[:],)', cache=True)
def func(x_left, x_right):
  for x_l,x_r in zip(x_left,x_right):
      ans[x_l:x_r] += 1
 
while True:
  if np.all(d==n):
    ans = d
    break
 
  if cnt == k or cnt==100:
    break
 
  ans *= 0
  x_left = l-d
  x_left[x_left < 0] = 0
  x_right = l+d+1
  x_right[x_left > n] = n
  func(x_left, x_right)
  cnt += 1
  d = ans.copy()
 
  
print(' '.join(map(str, ans)))

Submission status: Runtime Error

Solution code:
from itertools import accumulate

N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

current_arr = A
if K > 41:
    print(" ".join([N]*N))
    exit()
for _ in range(K):
    imos = [0] * N
    ruiseki = [0] * (N+1)
    for i, ai in enumerate(current_arr):
        imos[max([0, i-ai])] += 1
        if i+ai+1 < N:
            imos[i+ai+1] -= 1
    for j, im in enumerate(imos):
        ruiseki[j+1] = ruiseki[j] + im
    current_arr = ruiseki[1:]
#print(imos)
#print(ruiseki)
#print(*accumulate(imos))
print(*current_arr)

Submission status: Runtime Error

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

for k in range(K):
    if len(set(A)) == 1:
        break
    B = [0] * N
    for n in range(N):
        L = max(0, n-A[n])
        R = min(N-1 , n + A[n])
        B[L] += 1
        if R+1 != N:
            B[R+1] -= 1
    
    ruiseki = [0] * N
    ruiseki[0] = B[0]
    for i in range(1,N):
        ruiseki[i] = ruiseki[i-1] + B[i]
        
    A = ruiseki[:]
print(*ruiseki,sep=" ")

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
for _ in range(n**0.5+1):
  add_a=[0]*(n+1)
  for i in range(n):
    a[i]
    add_a[max(0,i-a[i])]+=1
    add_a[min(n,i+a[i]+1)]-=1
  tmp=0
  for i in range(n):
    tmp+=add_a[i]
    a[i]=tmp
print(' '.join(map(str,a)))

Submission status: Runtime Error

Solution code:
@njit
def solve():
  import sys
  readline=sys.stdin.readline
  
  N,K = map(int,readline().split())
  A = list(map(int,readline().split()))
  def calc(A):
      B = [0] * len(A)
      for i in range(len(A)):
          B[max(0,i - A[i])] += 1
          if i + A[i] + 1 < len(A):
              B[i + A[i] + 1] -= 1
      for i in range(1,len(B)):
          B[i] = B[i - 1] + B[i]
      return B
  
  for i in range(K):
    A = calc(A)
    if len(set(A)) == 1 and A[0] == N:
      print(*A)
      break
  else:
    print(*A)
  
solve()

Submission status: Runtime Error

Solution code:
from numba import jit
import sys
input = sys.stdin.readline


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

for _ in range(K):
    B = [0]*(N+1)
    for i, a in enumerate(A):
        B[max(0, i-a)] += 1
        B[min(N, i+a+1)] -= 1
    for j in range(1, N):
        B[j] += B[j-1]
    if A == B[:-1]:
        A = B[:-1]
        break
    A = B[:-1]

ans = ' '.join(list(map(str, A)))
print(ans)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline


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

    for _ in range(K):
        B = [0]*N
        for i, a in enumerate(A):
            bottom = max(0, i-a)
            top = min(N, i+a+1)

            # B[bottom:top] = list(map(lambda x: x+1, B[bottom:top]))
            B[bottom] += 1
            B[top] -= 1
        for j in range(1, N):
            B[j] += B[j-1]

        if A == B:
            A = B[:]
            break
        A = B[:]

    ans = ' '.join(list(map(str, A)))
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import njit

@njit(cache=True)
def light(n,a_list):
    outcome= np.zeros(n+1, dtype=np.int64)
    for i in range(n):
        outcome[max(0,i-a_list[i])] += 1
        outcome[min(n,i+a_list[i]+1)] -= 1
    outcome = np.cumsum(outcome)[:-1]
    return outcome
 
for _ in range(k):
    if min(a) == n:
        break
    a = light(n,a)
 
[print(aa,end=' ') for aa in a]

Submission status: Runtime Error

Solution code:
@njit(cache=True)
def light(n,a_list):
    outcome= np.zeros(n+1, dtype=np.int64)
    for i in range(n):
        outcome[max(0,i-a_list[i])] += 1
        outcome[min(n,i+a_list[i]+1)] -= 1
    outcome = np.cumsum(outcome)[:-1]
    return outcome
 
for _ in range(k):
    if min(a) == n:
        break
    a = light(n,a)
 
[print(aa,end=' ') for aa in a]

Submission status: Runtime Error

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

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

dp = [[0] * 2 for i in range(n)]

ans = l[:]

if k > 10**:
    k = 100
    
for i in range(k):
    for j in range(n):
        dp[j][0] = (j+1 - ans[j] - 0.5)
        dp[j][1] = (j+1 + ans[j] + 0.5)

    ans = [0] * n

    for x in range(n):
        for y in range(n):
            if dp[y][0] <= x+1 <= dp[y][1]:
                ans[x] += 1
else:
    print(*ans)

Submission status: Runtime Error

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

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

dp = [[0] * 2 for i in range(n)]

ans = l[:]

if k > 10**:
    k = 100
    
for i in range(k):
    for j in range(n):
        dp[j][0] = (j+1 - ans[j] - 0.5)
        dp[j][1] = (j+1 + ans[j] + 0.5)

    ans = [0] * n

    for x in range(n):
        for y in range(n):
            if dp[y][0] <= x+1 <= dp[y][1]:
                ans[x] += 1

else:
    print(*ans)

Submission status: Runtime Error

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

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

for i in range(min(41,K)):
  A = s(N,A)
  
print(A)

Submission status: Runtime Error

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

def s(n,a):
  b = [0]*n
  for i in range(n):
    l = max(0,i-a[i])
    r = min(n-1,i+a[i])
    b[l] += 1
    if r < N - 1:
      b[r+1] -= 1
  for i in range(n):
    b[i+1] = b[i]
  return b

for i in range(min(41,K)):
  A = s(N,A)
  
print(A)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
 
for _ in range(K):
  　if A == [N] * N:
        break
    else:
    B = [sum(abs(x -y) <= A[y] for y in range(N)) for x in range(N)]
    A = B
 
print(' '.join(map(str, A)))

Submission status: Runtime Error

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

A_list = [0]+list(map(int, input().split()))
A_np=np.array(A_list)
#print(A_np)

for j in range(K):
  new_A=[0]*(N+1)
  for i in range(1,N+1):
    #print(A_np)
    mi=i-A_np[i]
    ma=i+A_np[i]
    if mi<0:
      mi=0
    if ma>N:
      ma=N
    new_A_np[mi:ma+1]=1
  A_np=new_A_np
  if sum(A_np[1:N+1])==N*N:
    break
    
for i in range(1,N+1):
  print(A_np[i],end=" ")

Submission status: Runtime Error

Solution code:
import numpy as np


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


    for _ in range(K):
        counter=[0 for _ in range(N)]

        for i in range(len(A)):
            left=max(0,i-A[i])
            right=min(N-1,i+A[i])
            counter[left]+=1
            if right+1<N:
                counter[right+1]-=1
        for i in range(len(counter)-1):
            counter[i+1]+=counter[i]

        if counter==A:
            break
        else:
            A=counter

    for i in range(N):
        if i!=N-1:
            print(str(A[i])+" ",end="")
        else:
            print(A[i])

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def main():  
  N = int(input())
  VW = [list(map(int,input().split())) for _ in range(N)]
  Q = int(input())
  vL = [list(map(int,input().split())) for _ in range(Q)]
  M = 0
  import math
  from collections import deque
  for q in range(Q):
    x = vL[q][1]
    if x>M:
      M = x

  D = int(math.log2(N)) + 1
  K = D//2
  Ddp = deque([[0] * (M+1) for _ in range(2**K)])

  for q in range(Q):
    v,L = vL[q]
    if v<=2**K - 1:
      print(Ddp[v][L])
      continue
    
main()

Submission status: Runtime Error

Solution code:
import numpy as np


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


    for _ in range(K):
        counter=[0 for _ in range(N)]

        for i in range(len(A)):
            left=max(0,i-A[i])
            right=min(N-1,i+A[i])
            counter[left]+=1
            if right+1<N:
                counter[right+1]-=1
        for i in range(len(counter)-1):
            counter[i+1]+=counter[i]

        if counter==A:
            break
        else:
            A=counter

    print(A)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import numpy as np

def count_num_light(a):
  ret = [0 for _ in range(len(a))]
  n = len(a)
  for i in range(n):
    start = max(0, i-a[i])
    end = min(n-1, i+a[i])
    ret[start] += 1
    if end+1 < n:
      ret[end+1] -= 1
  for i in range(1,n):
    ret[i] += ret[i-1]
  
  return ret
                  
n, k = map(int, input().split())
a = list(map(int, input().split()))
num_light = count_num_light(a)
 
for i in range(k-1):
  num_light = count_num_light(num_light)
  if np.all(num_light, n):
    break
    
print(*num_light)

Submission status: Runtime Error

Solution code:
#import numpy as np
N, K= map(int,input().split())
A = list(map(int,input().split()))
a=A[:]
for _ in range(K)
  B=[0]*(N+1)
  for i in range(N):
    t = a[i]
    B[max(i-t,0)] +=1
    B[min(i+t+1,N)] -=1
  for i in range(N):
    B[i+1] += B[i]
    a=B[:N]        
  if min(a)==N:
    break
print(*a)

Submission status: Runtime Error

Solution code:
def count_num_light(a):
  ret = [0 for _ in range(len(a))]
  for i in range(len(a)):
    start = max(0, i-a[i])
    for j in range(start, i+a[i]+1):
      ret[j] += 1
  
  return ret
                  
n, k = map(int, input().split())
a = list(map(int, input().split()))
num_light = count_num_light(a)

for i in range(k-1):
  num_light = count_num_light(num_light)
  if sum(num_light) == n**2:
    break

print(*num_light)

Submission status: Runtime Error

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

from itertools import accumulate
    
for _ in range(K):
	ans=[0]*(N+1)
    for i,a in enumerate(A):
        ans[max(0,i-a)]+=1
        ans[min(i+a+1,N)]-=1
    A = list(accumulate(ans))[:-1]
    if all(i == N for i in A):
        break
print(*A)

Submission status: Runtime Error

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

@jit   # 高速化
def imo(a, n):
    imos = np.zeros(n+1)
    for i in range(n):
        imos[max(0, i-a[i])] += 1
        imos[min(n, i+a[i])+1] -= 1

    # 累計和はnumpyの方が高速
    immo = np.zeros(n+1)
    immo = np.cumsum(imos)

    return immo[:n]


for _ in range(min[K, 41]):
    A = imo(A, N)

print(*A)

Submission status: Runtime Error

Solution code:
check

Submission status: Runtime Error

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

for i in range(K):
  newLightPow = [0]*N
  for pos in range(1, N+1):
    count = 0
    low = max(math.ceil(pos-(lightPow[pos-1]+0.5)), 1)
    high = max(math.floor(pos+(lightPow[pos-1]+0.5)), 1)

    for area in range(low, high+1):
      newLightPow[area-1] += 1
    #print(pos)
    #print("low"+str(low)+" high"+str(high))
    #print(newLightPow)
  lightPow = newLightPow
  
print(*lightPow)

Submission status: Runtime Error

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

zero = [0 for i in range(N)]
for i in range(min(K,41)):
    B_n[:] = zero
    for j in range(N):
        B_n[max(0 ,j -A_n[j]):min(N ,j + A_n[j]+1)] = map(lambda x : x+1,B_n[max(0 ,j -A_n[j]):min(N ,j + A_n[j]+1)])
    A_n[:] = B_n
print(" ".join(map(str,B_n)))

Submission status: Runtime Error

Solution code:
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
for j in range(min(K,2*(math.log2(N))+1)):
	B = [0]*N
	for i in range(N):
		l = max(0,i-A[i])
		r = min(N-1,i+A[i])
		B[l] += 1
		if r < N-1:
			B[r+1] -= 1
	for i in range(1,N):
		B[i] += B[i-1]
	A = B
print(' '.join(map(str,A)))

Submission status: Runtime Error

Solution code:
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
for j in range(min(K,2*(math.log2(N)+1))):
	B = [0]*N
	for i in range(N):
		l = max(0,i-A[i])
		r = min(N-1,i+A[i])
		B[l] += 1
		if r < N-1:
			B[r+1] -= 1
	for i in range(1,N):
		B[i] += B[i-1]
	A = B
print(' '.join(map(str,A)))

Submission status: Runtime Error

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

zero = [0 for i in range(N)]
for i in range(min(K,41)):
    B_n[:] = zero[:]
    for j in range(N):
        B_n[max(0 ,j -A_n[j]):min(N ,j + A_n[j]+1)] = map(lambda x : x+1,B_n[max(0 ,j -A_n[j]):min(N ,j + A_n[j]+1)])
        
    A_n[:] = B_n[:]
print(" ".join(map(str,B_n)))

Submission status: Runtime Error

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

zero = [0 for i in range(N)]
for i in range(min(K,41)):
    B_n[:] = zero[:]
    for j in range(N):
        B_n[max(0 ,j -A_n[j]):min(N ,j + A_n[j]+1)] =(
            map(lambda x : x+1,B_n[max(0 ,j -A_n[j]):min(N ,j + A_n[j]+1)]))
        
    A_n[:] = B_n[:]
print(" ".join(map(str,B_n)))

Submission status: Runtime Error

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

@njit(cache = True)
def main(N, K, A):
    A = np.array(A, dtype = int)
    for k in range(K):
        # print(k)
        B = np.zeros(N + 1, dtype = int)
        for x in range(N):
            minimum = max(0, x - A[x])
            maximum = min(N, x + A[x] + 1)
            # B[minimum:maximum] += 1
            B[minimum] += 1
            B[maximum] -= 1
            A = np.cumsum(B)[:-1]
        if np.all(A == N):
            # print(k)
            break
    print(' '.join([str(i) for i in A]))



if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    main(N, K, A)

Submission status: Runtime Error

Solution code:
import numpy as np
import numba

b_n, i_k = map(int, input().split())
lamps = np.array([int(x) for x in input().split()])
act = np.zeros(b_n, dtype=np.int64)

%numba.jit
def loop(n, k, lamps, act):
    one = np.ones(n, dtype=np.int64)
    init = lamps
    for i in range(k):
        act[:] = 0
        for i in range(n):
            if init[i] == 0:
                continue
            dmin = i - int(init[i])
            dmax = i + int(init[i])
            if dmin < 0:
                dmin = 0
            if dmax > n-1:
                dmax = n-1
            act[dmin:dmax+1] += 1
            act[i] -= 1
        init = act + one
    return init
result = loop(b_n, i_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
# from numba import jit

# @jit(cache = True)
def main(N, K, A):
    A = np.array(A, dtype = int)
    for k in range(K):
        # print(k)
        B = np.zeros(N, dtype = int)
        for x in range(N):
            minimum = max(0, x - A[x])
            maximum = min(N, x + A[x] + 1)
            # B[minimum:maximum] += 1
            B[minimum] += 1
            B[maximum] -= 1
            A = np.cumsum(B)
        if np.all(A == N):
            # print(k)
            break
    print(' '.join([str(i) for i in A]))



if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    main(N, K, A)

Submission status: Runtime Error

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


for i in range(K):
    cum_sum = np.array([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]
    for j in range(N-1):
        cum_sum[j+1] += cum_sum[j]
        A[j+1] = cum_sum[j+1]

    if A[0] == N and A[N-1] == N:
        break
    
        
for i in range(N):
    print(A[i], " ", end = "")
print()

Submission status: Runtime Error

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

K = min(K, 100)
for _ in range(K):
    B = [0 for _ in range(A)]
    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.copy()

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

Submission status: Runtime Error

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

K = min(K, 100)
for i in range(K):
    B = [0 for _ in range(A)]
    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.copy()

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

Submission status: Runtime Error

Solution code:
N, K = map(int,input().split())
A = list(map(int,input().split()))
for t in range(K):
  B =[0 for i in range(N)]
  for i in range(N):
	tp = 0
    for j in range(N):
      	if abs(i-j) <= A[j]:
        	tp+=1
    B[i] = tp
  A=B
print(*A)

Submission status: Runtime Error

Solution code:
n,k,*l = map(int,open(0).read().split())
from numba import njit
import copy
import numpy as np
import sys
@njit('(i8[::1],)', cache=True)
def loop(n,k,l):
    for i in range(k):
        ll = np.array([0] * n)
        for j, e in enumerate(l):
            ll[max(0,j-e):min(n,j + e+1)] += 1

        l =copy.deepcopy(ll)

        if np.all(l == n):
            break
    
    return l

l =  loop(n,k,l)

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

Submission status: Runtime Error

Solution code:
import numpy as np
# import math


b_n, i_k = map(int, input().split())
b_h = b_n
# tmp = input()
# 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((10000,100000))
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(b_n, i_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())
a1 = list(map(int, input().split()))
a = np.asarray(a1, dtype=int)
if k<int(math.exp(int(n))):
    for i in range(k):
        b = np.zeros(n, dtype=int)
        for j in range(n):
            mi = j-a[j]
            ma = j+a[j]
            if mi<0:
                mi = 0
            if ma>=n:
                ma = n-1
            b[mi:ma+1:]+=1
        a = b
    print(*a)
else:
    ans = np.asarray(n, dtype=int)
    print(*ans)

Submission status: Runtime Error

Solution code:
from itertools import accumulate

def main():
    n, k = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    
    # for _ in range(min(k,int(math.log(n,2)))):
    
    
    def solve():
        nonlocal A
        for _ in range(k):
            b=[0]*(n+1)
            
            for i in range(n):
                b[max(0,i-A[i])]+=1
                b[min(n,i+A[i]+1)]-=1
            
            # update ans
            # cnt=0
            # for i in range(1,n):
            #     b[i]+=b[i-1]
            a=[*accumulate(b)]
            A=b
            if min(A)==n:
                break
        print(*A[:-1])
    solve()

if '__main__' == __name__:
    main()

Submission status: Runtime Error

Solution code:
import numpy as np
# import math


b_n, i_k = map(int, input().split())
b_h = b_n
# tmp = input()
# 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((b_n, i_k))
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(b_n, i_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


b_n, i_k = map(int, input().split())
b_h = b_n
# tmp = input()
# 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((b_n, b_h))
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(b_n, i_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
N,K=map(int,input().split())
A=np.array(list(map(int,input().split())),dtype=int64)
B=np.zeros(N+1,dtype=int64)
if K>41:
  A=np.ones(N,dtype=int64)*N
else:
  for k in range(K):
    for i in range(N):
      B[max(0,i-int(A[i]))] +=1
      B[min(N,i+int(A[i])+1)] -=1
    A=np.cumsum(B)[:N]
    B=np.zeros(N+1,dtype=int64)

for i in A:
  print(i)

Submission status: Runtime Error

Solution code:
import numpy as np
# import math


b_n, i_k = map(int, input().split())
# tmp = input()
# 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((b_n, b_n))
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(b_n, i_k, lamps, act)
# ans = list(map(str,result.tolist()))
# print(" ".join(ans))
result = ""
print(result)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np

def input():
    return sys.stdin.readline()[:-1]


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

for _ in range(k):
    b_li = [0 for _ in range(n)]
    for i in range(n):
        l = max(0, i-a_li[i])
        r = min(n-1, i+a_li[i])
        for j in range(l, r+1):
            b_li[j] += 1
    a_li = b_li
    
print(' '.join(map(str, a_li)))

Submission status: Runtime Error

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

#累積和
for _ in range(K):
    B = [0]*(N+1)
    for i in range(N):
        l = max(0,i-A[i])
        r = min(N-1, i+A[i])
        B[l] += 1
        B[r+1] -= 1
    for i in range(1,N):
        B[i] += B[i-1]
    A = B
    if min(A) == N:
        break
A.pop()
print(*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,np.int64)

@njit('(i8[::1],)', cache=True)
def imo(a):
    imos=np.zeros(n+1,np.int64)
    for i in range(n):
        imos[max(0,i-a[i])]+=1
        imos[min(n,i+a[i]+1)]-=1
    
    immo=np.zeros(n+1,np.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:
import numpy as np
# import math


N, K = map(int, input().split())
# tmp = input()
# 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))
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 = input()
# 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="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 = input()
# 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 = input()
# 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)