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: Wrong Answer

Solution code:
import numpy as np
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(1):
  new_A_np=np.zeros(N+1,dtype=np.int16)
  for i in range(1,N+1):
    tmp_np=np.zeros(N+1,dtype=np.int16)
    #print(A_np)
    mi=i-A_np[i]
    ma=i+A_np[i]
    if mi<0:
      mi=0
    if ma>N:
      ma=N
    #print(mi,ma)
    tmp_np[mi:ma+1]=1
    #print(tmp_np)
    new_A_np+=tmp_np
  #print(new_A_np)
  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: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
l = [0]*N
for k in range(K):
    if math.log2(N) <= k:
        break
    else:
        for i in range(N):
            m = max(0, i-A[i])
            M = min(i+A[i], N-1)
            l[m] += 1
            if M < N-1:
                l[M+1] -= 1
        for i in range(1, N):
            l[i] += l[i-1]
            A[i-1] = l[i-1]
            l[i-1] = 0
        A[N-1] = l[N-1]
        l[N-1] = 0
print(*A, sep=" ")

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
l = [0]*N
for k in range(K):
    if math.log2(N) <= k:
        break
    else:
        for i in range(N):
            m = max(0, i-A[i])
            M = min(i+A[i], N-1)
            l[m] += 1
            if M < N-1:
                l[M+1] -= 1
        for i in range(1, N):
            l[i] += l[i-1]
            A[i-1] = l[i-1]
            l[i-1] = 0
        A[N-1] = l[N-1]
        l[N-1] = 0
print(A)

Submission status: Wrong Answer

Solution code:
import numpy as np
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(1):
  new_A_np=np.array([0]*(N+1))
  for i in range(1,N+1):
    tmp_np=np.array([0]*(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
    #print(mi,ma)
    tmp_np[mi:ma+1]=1
    #print(tmp_np)
    new_A_np+=tmp_np
  #print(new_A_np)
  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: Wrong Answer

Solution code:
import numpy as np
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(43):
  new_A_np=np.array([0]*(N+1))
  for i in range(1,N+1):
    tmp_np=np.array([0]*(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
    #print(mi,ma)
    tmp_np[mi:ma+1]=1
    #print(tmp_np)
    new_A_np+=tmp_np
  #print(new_A_np)
  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: Wrong Answer

Solution code:
import math

n,k = map(int,input().split())
lamps = list(map(int,input().split()))
lights = [0 for i in range(n)]

for i in range(k):
  for j in range(n):
    lights[max(0,j-lamps[j])] += 1
    right = min(n,j+lamps[j]+1)
    if right != n:
      lights[right] -= 1
  print(lights)
  for j in range(1, n):
    lights[j] = lights[j] + lights[j-1] 
  lamps = lights[:]
  lights = [0 for i in range(n)]
  if i >= 41:
    lamps = [n for i in range(n)]
    break

l = [str(a) for a in lamps]
l = " ".join(l)
print(l)

Submission status: Wrong Answer

Solution code:
import math

n,k = map(int,input().split())
lamps = list(map(int,input().split()))
lights = [0 for i in range(n)]

for i in range(k):
  for j in range(n):
    lights[max(0,j-lamps[j])] += 1
    right = min(n,j+lamps[j]+1)
    if right != n:
      lights[right] -= 1
  print(lights)
  for j in range(1, n):
    lights[j] = lights[j] + lights[j-1] 
  lamps = lights[:]
  lights = [0 for i in range(n)]
  if i >= math.log2(n):
    lamps = [n for i in range(n)]
    break

l = [str(a) for a in lamps]
l = " ".join(l)
print(l)

Submission status: Wrong Answer

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

for i in range(K):
  newLightPow = [0]*N
  #print(lightPow)
  for pos in range(1, N+1):
    count = 0
    low = math.ceil(pos-(lightPow[pos-1]+0.5))
    high = math.floor(pos+(lightPow[pos-1]+0.5))
    low = min(max(1, low), N)
    high = min(max(1, high), N)
    for area in range(low, high+1):
      #print(area)
      newLightPow[area-1] += 1
    #print("pos:"+str(pos))
    #print("low"+str(low)+" high"+str(high))
    #print(newLightPow)
  lightPow = newLightPow
  check = True
  for pow in lightPow:
    if (pow < (N-1)) :
      check = False
    if not (check):
      break
  if not (check):
    break
  
print(*lightPow)

Submission status: Wrong Answer

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

a_tmp = [0] * n
a_range = [0]*n
#print(a_tmp)

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k):
    b = [0 for i in range(n + 1)]
    for i in range(n):
        l = max(0, i - a[i])
        r = min(n, i + a[i] + 1)
        b[l] += 1
        b[r] -= 1
    for i in range(len(b)-1):
        b[i+1] += b[i]
    b = b[:n]
    if a == b:
        break
    else:
        a = b
print(b)

Submission status: Wrong Answer

Solution code:
n,k_ = map(int,input().split())
a_li = list(map(int,input().split()))
a_li_o = [0]*n
for i in range(k_):
    for l in range(n):
        a_li_o[l] = a_li[l]
    dum_li = [0]*n
    for j in range(n):
        left = j - a_li[j]
        right = j + a_li[j] + 1
        if left < 0:
            left = 0
        dum_li[left] += 1
        if right > n-1:
            continue
        dum_li[right] -= 1
    total = 0
    for k in range(n):
        total += dum_li[k]
        dum_li[k] = total
    for k in range(n):
        a_li[k] = dum_li[k]
    if a_li_o == a_li:
        break
print(a_li)

Submission status: Wrong Answer

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

def f(A):
  D=[0]*(N+1)
  for j in range(N):
    d=A[j]
    mi=max(j-A[j],0)
    ma=min(j+A[j],N-1)
    D[mi]+=1
    D[ma+1]-=1   
  A=list(np.cumsum(D))
  return A 

for i in range(min(K,42)):
  A=list(f(A))

Submission status: Wrong Answer

Solution code:
import numpy as np
N, K= map(int,input().split())
A = list(map(int,input().split()))
p=0
while p<K:
  B=[0]*(N+1)
  for i in range(N):
    l = max(i-A[i],0)
    r = min(i+A[i]+1,N)
    B[l] +=1
    B[r] -=1
  A = np.cumsum(B)
  p +=1        
  if min(A[0:N-1])==N:
    break
print(*A[0:N-1])

Submission status: Wrong Answer

Solution code:
import numpy as np

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

for i in range(int(np.log(k))+1):
  num_light = count_num_light(num_light)

print(*num_light)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

for i in range(int(np.log(n))+1):
  num_light = count_num_light(num_light)

print(*num_light)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

for i in range(int(np.log(n))+1):
  num_light = count_num_light(num_light)
  if np.sum(num_light) == n**2:
    break

print(*num_light)

Submission status: Wrong Answer

Solution code:
# 累積和
import numpy as np

def loop(n,k,A):
    for _ in [0] * k:
        B = np.zeros(n + 1, dtype=np.int64)
        for i in range(n):
            left = max(0, i - A[i])
            right = min(n, i + A[i] + 1)
            B[left] += 1
            B[right] -= 1
        A = np.cumsum(B)[:-1]
        if np.all(A == n):
            return(A)
            break

    print(*A)

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    A = np.array(a, dtype=np.int64)
    loop(n, k, A)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# 累積和
import numpy as np

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    A = np.array(a, dtype=np.int64)
    for _ in [0] * k:
        B = np.zeros(n + 1, dtype=np.int64)
        for i in range(n):
            left = max(0, i - A[i])
            right = min(n, i + A[i] + 1)
            B[left] += 1
            B[right] -= 1
        A = np.cumsum(B)[:n + 1]
        if np.all(A == n):
            break

    print(*A)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#import numpy as np
N, K = tuple(int(c) for c in input().split(' '))
A = [N] * (N+1)
print(' '.join([str(s) for s in A[1:]]))

Submission status: Wrong Answer

Solution code:
import numpy as np
N, K= map(int,input().split())
A = list(map(int,input().split()))
p=0
while p<K:
  B=[0]*(N+1)
  for i in range(N):
    l = max(i-A[i],0)
    r = min(i+A[i]+1,N)
    B[l] +=1
    B[r] -=1
  A = np.cumsum(B)
  p +=1        
  if min(A)==N:
    break
print(*A)

Submission status: Wrong Answer

Solution code:
# 累積和
import numpy as np


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    A = np.array(a, np.int64)
    if not (min(A) == 0 and max(A) == 0):
        for _ in [0] * k:
            B = np.zeros(n + 1, np.int64)
            for i in range(n):
                left = max(0, i - A[i])
                right = min(n, i + A[i] + 1)
                B[left] += 1
                B[right] -= 1
            A = np.cumsum(B)[:n]
            if np.all(A == n):
                break

    print(*A)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# 累積和
import numpy as np


def main():
    n, k = map(int, input().split())
    A = np.array(list(map(int, input().split())))
    if not (min(A) == 0 and max(A) == 0):
        for _ in [0] * k:
            B = np.zeros(n + 1, np.int64)
            for i in range(n):
                left = max(0, i - A[i])
                right = min(n, i + A[i] + 1)
                B[left] += 1
                B[right] -= 1
            A = np.cumsum(B)[:n]
            if min(A) == n:
                break

    print(*A)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
b = [0]*N
def add_lit(i, d):
	for x in range(i-d,i+d+1):
		if x < 0 or x >= N:
			continue
		else:
			b[x] += 1
	return b

def put_list(inlist):
	for i in range(0,N):
		add_lit(i, inlist[i])

for k in range(K):
	if k == 0:
		put_list(A)
	else:
		A = b
		b = [0]*N
		put_list(A)

print(b)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

for _ in range(43):
    S = [0] * (N + 1)
    for i, a in enumerate(A):
        l = min(N-1, max(0, i-a))
        r = min(N-1, i+a)
        S[l] += 1
        S[r+1] -= 1
    t = 0
    for i in range(N):
        t += S[i]
        A[i] = t
print(*A)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

for _ in range(42):
    S = [0] * (N + 1)
    for i, a in enumerate(A):
        l = min(N-1, max(0, i-a))
        r = min(N-1, i+a)
        S[l] += 1
        S[r+1] -= 1
    t = 0
    for i in range(N):
        t += S[i]
        A[i] = t
print(*A)

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
for j in range(min(K,int(2*(math.log2(N)))+2)):
	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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
for j in range(min(K,int(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: Wrong Answer

Solution code:
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))  # 整数のリスト
    B = [0] * N

    for j in range(K, 41):
        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
        B = [0] * N

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
lst = list(map(int, input().split()))
for i in range(40):
    lit = [0 for _ in range(n)]
    for _ in range(0, n):
        mx = max(0,_ - lst[_])
        mn = min(n, _ + lst[_] +1)
        lit[mx:mn] = map(lambda x:x+1, lit[mx:mn])
    lst = lit
lst = [str(_) for _ in lst]
ans = ' '.join(lst)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
from numba import jit
# -- numba (jit compile) ------------
@jit
def calc(x, zero, BB):
    for j in range(1, x + 1):
        pp = BB[j - 1]

        if (pp == 0):
            zero[int(j - 1)] += 1
            # print(d)
            continue
        if (pp == x):
            zero += 1
            '''
            if (k - i > (n//2)):
                ans = [str(i) for i in check]
                # print(ans)
                print(' '.join(ans))
                exit()
            # print(d)
            '''
            continue

        left = j - BB[j - 1] - 1
        # print(left)
        if (left < 0):
            left = 0
        right = j + BB[j - 1]
        #print('R: ',right)
        if (right > x - 1):
            right = x
        #print('L&R: ', left, right)

        zero[int(left): int(right)] += 1
        #print(j, d)

    return zero


# ---- read ---------------------------------
n, k = map(int, input().split())
a = list(map(int, input().split()))
bb = np.array(a, dtype=np.int64)
# print(bb)
check = np.full(n, n, dtype=np.int64)
# --- main ----------------------------
for i in range(k):
    #d = [0] * n
    print(i)
    d = np.zeros(n, dtype=np.int64)
    d = calc(n, d, bb)
    bb = d

    if (all(bb == check)):
        break

# -------------------------------
ans = [str(i) for i in bb]
# print(ans)
print(' '.join(ans))

Submission status: Wrong Answer

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 + 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: Wrong Answer

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 + 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: Wrong Answer

Solution code:
N, K = map(int,input().split())
A = list(map(int,input().split()))
B=[0]*N
for t in range(K):
  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: Wrong Answer

Solution code:
n,k=map(int,input().split())
arr=list(map(int,input().split()))
for i in range(k):
    b=[0]*(n)
    c=0
    for j in range(n):
        if j-arr[j]>=0:
            b[j-arr[j]]+=1
        else:
            b[0]+=1
        if j+arr[j]+1<n:
            b[j+arr[j]+1]-=1
    for i in range(1,n):
        b[i]=b[i]+b[i-1]
    for i in range(n):
        if b[i]==n:
            c+=1
    if c==n:
        break
    arr=b.copy()
print(b)

Submission status: Wrong Answer

Solution code:
import numpy as np
from numba import jit
@jit
def op(A, n):
    B = np.zeros_like(A)
    for i, a in enumerate(A):
        B[max(i - a, 0)] += 1
        r = min(n - 1, a + i)
        if r < n - 1:
            B[r + 1] -= 1
    return np.cumsum(B)

def main():
    n, k = list(map(int, input().split()))
    A = np.array(list(map(int, input().split())), dtype = np.int)
    if k >= np.log2(n) + 1:
        print(' '.join([str(n)] * n))
    else:
        for _ in range(k):
            A = op(A, n)
        print(' '.join(list(map(str, A))))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
b = [0]*N
def add_lit(i, d):

	for x in range(i-d,i+d+1):
		if x < 0 or x >= N:
			continue
		else:
			b[x] += 1
	return b

def put_list(inlist):
	for i in range(0,N):
		add_lit(i, inlist[i])

for k in range(K):
	if k == 0:
		put_list(A)
	else:
		A = b
		b = [0]*N
		put_list(A)

print(b)

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
for j in range(min(K,int(math.log2(N)+2))):
	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: Wrong Answer

Solution code:
N, K = map(int,input().split())
A = list(map(int,input().split()))
B=[0 for i in range(N)]
for t in range(K):
  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: Wrong Answer

Solution code:
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
for j in range(min(K,int(math.log2(N)))):
	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: Wrong Answer

Solution code:
a,b=map(int,input().split())
import numpy as np
l=np.array(list(map(int,input().split())))
for i in range(min(b,50)):
  y=np.zeros(a,dtype=np.int)
  for j in range(a):
    x=l[j]
    y[max(0,j-x)]+=1
    r=min(j+x,a-1)
    if r<a-1:
      y[r+1]-=1
  print(y)
  l=np.cumsum(y)
print(*l)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
import numpy as np
l=np.array(list(map(int,input().split())))
for i in range(min(b,100)):
  y=np.zeros(a,dtype=np.int)
  for j in range(a):
    x=l[j]
    y[max(0,j-x)]+=1
    r=min(j+x,a-1)
    if r<a-1:
      y[r+1]-=1
  print(y)
  l=np.cumsum(y)
print(*l)

Submission status: Wrong Answer

Solution code:
import copy
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [0]*N


for _ in range(K):
    if all(e >= N for e in A):
        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 j in range(1,N):
        B[j] += B[j-1]
    A = copy.copy(B)




for _ in A:
    print(_, end=' ')

Submission status: Wrong Answer

Solution code:
# 累積和
import numpy as np


def main():
    n, k = map(int, input().split())
    A = np.array(list(map(int, input().split())))
    if not ( min(A) == 0 and max(A) == 0 ):
        for _ in [0] * k:
            new_A = np.array([0] * (n+1))
            for i in range(n):
                left = max(0, i - A[i])
                right = min(n, i + A[i] + 1)
                new_A[left] += 1
                new_A[right] -= 1
            A = np.add.accumulate(new_A)[:n]
            
            if min(A) == n:
                break

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import copy

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

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

    for j in range(n):
        b[j + 1] += b[j]
    b = b[:-1]

    if b == a:
        break
    a = copy.deepcopy(b)
print(a)

Submission status: Wrong Answer

Solution code:
import copy
from functools import lru_cache
#import numpy as np
#from numba import njit

def resolve():
    N, K = map(int, input().split())
    #A = np.array(list(map(int, input().split())))
    A = list(map(int, input().split()))

    #N = 2 * 10**5
    #K = 2 * 10**5
    #A = np.array([0] *  N)

    def func(A):
        B = [0] * N
        for i in range(N):
            l = max(0, i - A[i])
            r = min(i + A[i], N-1)
            B[l] += 1
            if r+1 < N:
                B[r+1] -= 1

        for i in range(1, N):
            B[i] += B[i-1]
        return B

    for k in range(K):
        print(k)
        A = func(A)
        if k >= 50:
            break

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

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
import numpy as np
N, K = map(int, input().split(" "))
As = np.array(list(map(int, input().split(" "))), dtype=int)
assert len(As) == N

for k in range(K):
  count = np.zeros(N, dtype=int)
  for i, a in enumerate(As):
    # count[max([0, i - a]):min([N, i+a+1])] += 1
    l = max([0, i - a])
    r = min([N-1, i+a])
    count[l] += 1
    if r + 1 < N: count[r+1] -= 1
  print(count)
  As = np.cumsum(count)
print(" ".join(list(map(str, As))))

Submission status: Wrong Answer

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((10,11))
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: Wrong Answer

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, 5))
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: Wrong Answer

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: Wrong Answer

Solution code:
import math
import numpy as np
def main():
    n, k = list(map(int, input().split()))
    A = np.array(list(map(int, input().split())))
    if k >= math.log2(n) + 1:
        print(' '.join([str(n)] * n))
    else:
        for _ in range(k):
            B = np.zeros_like(A)
            for i, a in enumerate(A):
                B[max(i - a, 0)] += 1
                r = min(n - 1, a + i)
                if r < n - 1:
                    B[r + 1] -= 1
            A = np.cumsum(B)
        print(' '.join(list(map(str, A))))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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((100, 100))
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: Wrong Answer

Solution code:
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=b
            if b[0]==n and b[-1]==n:
                break
        print(*A)
    solve()

if '__main__' == __name__:
    main()

Submission status: Wrong Answer

Solution code:
import sys
N, K = map(int, input().split())
if K > 25:
    print(" ".join(map(str, [N] * N)))
    sys.exit()
A = [int(i) for i in input().split()]
DP = [[0 for _ in range(N)] for _ in range(K+1)]
for i in range(N):
    DP[0][i] = A[i]

for i in range(1, K+1,1):
    B = [0] * N
    for j in range(N):
        pl, mi = min(j + DP[i-1][j], N-1), max(j - DP[i-1][j], 0)
        B[mi] += 1
        if pl + 1 < N:
            B[pl + 1] -= 1
    for j in range(1, N):
        B[j] += B[j-1]
    DP[i] = B
print(" ".join(map(str, DP[K])))

Submission status: Wrong Answer

Solution code:
import sys
N, K = map(int, input().split())
if N < 2 ** K - 1:
    print(" ".join(map(str, [N] * N)))
    sys.exit()
A = [int(i) for i in input().split()]
DP = [[0 for _ in range(N)] for _ in range(K+1)]
for i in range(N):
    DP[0][i] = A[i]

for i in range(1, K+1,1):
    B = [0] * N
    for j in range(N):
        pl, mi = min(j + DP[i-1][j], N-1), max(j - DP[i-1][j], 0)
        B[mi] += 1
        if pl + 1 < N:
            B[pl + 1] -= 1
    for j in range(1, N):
        B[j] += B[j-1]
    DP[i] = B
print(" ".join(map(str, DP[K])))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, K = map(int,input().split())
A = list(map(int,input().split()))
B =[0 for i in range(N)]
for t in range(K):
  for i in range(N):
    for j in range(N):
      	if i >= j-A[j] and i <= j+A[j]:
        	B[i]+=1
  A=B
  B=[0,0,0,0,0]
print(A)