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 math
from sys import stdin,stdout
#% 998244353
from heapq import heapify,heappop,heappush
import collections

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


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


        

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

Submission status: Wrong Answer

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


if K > 1000:
    A = [N] * N
else:
    for count in range(K):
        B = [0] * N
        for i in range(1,N+1):
            # i - A[i]以上、i + A[i]以下のBの要素に1を足す
            startIndex = i - A[i - 1] - 1
            endIndex = i + A[i -1] - 1
            if startIndex < 0:
                startIndex = 0
            if N < endIndex:
                endIndex = N - 1
            if startIndex <= i-1 and i-1 <= endIndex:
                B[i-1] = B[i-1] + 1
        A = B

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(1000):
    ans=[0]*(n)
    for j in range(n):
        l=max(0,j-a[j])
        r=j+1+a[j]
        ans[l]+=1
        if r<n:
            ans[r]-=1
    for z in range(n-1):
        ans[z+1]+=ans[z]
    a=ans
    if ans[0]==n and ans[n-1]==0:
        print(" ".join(list(map(str,ans))))
        sys.exit()
print(" ".join(list(map(str,ans))))

Submission status: Wrong Answer

Solution code:
N,K=100000,100000
A=[0]*100000

for i in range(K):
    B=[0]*(N+1)
    for j in range(N):
        l=max(0,j-A[j])
        r=min(N-1,j+A[j])
        B[l]+=1
        B[r+1]-=1
    for j in range(1,N):
        B[j]=B[j]+B[j-1]
    ok=True
    for j in range(N):
        if B[j]!=N:
            ok=False
            break
    if ok:
        print(*B[:N])
        exit()
        
    A=B.copy()
print(*A[:N])

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = input().split()
i_list = list(range(len(a)))
a = [int(a[i]) for i in i_list]
c = [0]*n
d = [0]*n

for i in range(n):
    dum = [i]*n
    d[i] = list(map(lambda y,z: abs(y-z), i_list, dum))

for m in range(max(k,50)):
    for i in range(n):
        b = list(map(lambda x,y: x-y, a, d[i]))
        c[i] = sum(1 for x in b if x >=0)
    a = []
    a += c
a = [str(aa) for aa in a]
print(' '.join(a))

Submission status: Wrong Answer

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

for _ in range(k):
    b = [0] * n
    for i in range(n):
        left = max(0, i - a[i])
        right = min(n-1, i + a[i])
        b[left] += 1
        if right + 1 < n: b[right + 1] -= 1

    for i in range(1, n):
        b[i] += b[i-1]
    a = b
    
    if k >= 50:
        break

print(*a)

Submission status: Wrong Answer

Solution code:
import numpy as np


n, k = map(int, input().split())
a = np.array(list(map(int, input().split())), dtype=np.uint16)

for ii in range(k):
    b = [0] * (n+1)
    for i, aa in enumerate(a):
        b[max(0, i - aa)] += 1
        b[min(i+aa+1, n)] -= 1
    a = np.cumsum(b, dtype=np.uint16)[:n]
    if np.min(a) == n:
        break

print(' '.join(np.array(a, dtype=str)))

Submission status: Wrong Answer

Solution code:
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]
if N%2 == 0:
    b = N//2
else:
    b = (N//2) +2
if N==1:
    print(1)
    exit()
if K >= 39:
    for i in range(N-1):
        print(N,end=" ")
    print(N)
    exit()
for k in range(K):
    nextgen = [0]*N
    for i in range(N):
        # print("i=",i)
        a = A[i]
        start = i-a
        if start <0:
            start = 0
        end = i+a+1
        if end <=N-1:
            nextgen[end] += -1
        nextgen[start] += 1
    dp = 0
    for i in range(N):
        dp += nextgen[i]
        A[i] = dp
s = ' '.join([str(i) for i in A])
print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

def action(A, N):
  B = [0] * N
  for i in range(N):
    s = max(0, math.ceil(i - A[i] - 0.5))
    e = min(N, math.ceil(i + A[i] + 0.5))
    for j in range(s, e):
      B[j] += 1 
  return B

def main():
  N, K = map(int, input().split())
  A = [int(s) for s in input().split()]

  for i in range(K):
    A = action(A, N)
    if A[0] == N & all(A):
      break
      
  print(A)

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
from copy import copy
N, K = map(int, input().split())
a = list(map(int, input().split()))
for x in range(K):
    print(x)
    b = [0] * N
    continue_Flag = False
    for y in range(N):
        for z in range(-1 * a[y], a[y] + 1, 1):
            if y + z >= 0 and y + z < N:
                b[y + z] += 1
        if a[y] != N:
            continue_Flag = True

    if not continue_Flag:
        break

    a = copy(b)
print(" ".join(map(str, a)))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

for i in range(k):
    
    if i > math.log(n):
        for z in range(len(alist)):
            alist[z] += (k-i)*len(alist)
        break
    new = [0] * n
    for j in range(n):
        distance = j - alist[j]
        if distance < 0:
            distance = 0
        last =  j + alist[j]
        if last > len(alist)-1:
            last = len(alist)-1
        new[distance]+=1
        if last+1 < len(alist):
            new[last+1]-=1
    for j in range(1,n):
        new[j] += new[j-1]
    alist = new
print(*alist)

Submission status: Wrong Answer

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

A=[int(i) for i in input().split()]
if K > N or K>25:
    output=""
    for i in range(N):
         output+=(str(N)+" ")
    print(output)
else:
    for _ in range(K):
        A_next =[1 for i in range(N)]
        for i in range(N):
            for j in range(A[i]):
                if (i+j+1) < N:
                    A_next[i+j+1]+=1
                if (i-j-1) >= 0:
                    A_next[i-j-1]+=1
        A=A_next
    output=""
    for i in A_next:
        output+=(str(i)+" ")
    print(output)

Submission status: Wrong Answer

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

K = max(K,1000)
for k in range(K):
  light = [0] * N
  for i in range(N):
    start = max(0,i-A[i])
    end = min(N-1, i+A[i])
    for j in range(start, end+1):
      light[j] += 1
    
  A = light

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

Submission status: Wrong Answer

Solution code:
N, K= input().strip().split()
N, K = [int(N), int(K)]
A = list(map(int, input().strip().split()))
B = [0]*N
for w in range(K):
    for i in range (N):
        for j in range(max(i-A[i],0),min(A[i]+i+1,N)):
            B[j]+=1
    for k in range(N):
        A[k]=B[k]
    for o in range(N):
        B[o]=0
    if A.count(N)==N:
        break
        
        
   


print(A)

Submission status: Wrong Answer

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

for _ in range(k):
    b = [0] * n
    for i in range(n):
        left = max(0, i - a[i])
        right = min(n-1, i + a[i])
        b[left] += 1
        if right + 1 < n: b[right + 1] -= 1

    a[0] = b[0]
    for i in range(1, n):
        a[i] = a[i-1] + b[i]
    
    if k >= 50:
        break

print(*a)

Submission status: Wrong Answer

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

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


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


        

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

Submission status: Wrong Answer

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

current_arr = A
for k in range(K):
    next_arr = [0]*N
    for i, ai in enumerate(current_arr):
        for num in range(-ai, ai+1):
            ii = i + num
            if ii < 0 or N <= ii:
                continue
            next_arr[ii] += 1
    current_arr = next_arr
    if not [x for x in next_arr if x != N]:
        break
print(next_arr)

Submission status: Wrong Answer

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

for _ in range(k):
    b = [0] * n
    for i in range(n):
        left = max(0, i - a[i])
        right = min(n-1, i + a[i])
        b[left] += 1
        if right + 1 < n: b[right + 1] -= 1

    a[0] = b[0]
    for i in range(1, n):
        a[i] = a[i-1] + b[i]
    
    if k >= 20:
        break

print(*a)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import time
t1=time.time()
def LI():return list(map(int,input().split()))
n,k=LI()
a=LI()

for _ in range(k):
    tab=[0]*(n)
    for i in range(n):
        q=a[i]
        if 0<=i-q:
            tab[i-q]+=1
        else:
            tab[0]+=1
        if i+q+1<=n-1:
            tab[i+q+1]-=1
        else:
            pass
    b=[tab[0]]
    for i in range(n-1):
        b.append(tab[i+1]+b[-1])
    if a==b:
        print(*a)
        break
    a=b[:]
    if time.time()-t1>1.5:
        print(*a)
        exit()
print(*a)

Submission status: Wrong Answer

Solution code:
import sys
N,K = map(int,input().split())
A = list(map(int,input().split()))
n = len(A)
fill = [0]*n
for z in range(K,100):
  i_count = [0]*n #座標iを照らすライトの数
  for i in range(1,n+1):
    light = A[i-1]
    for x in range(i-light,i+light+1):
      if x >= 1 and x <= n:
        i_count[x-1] += 1
        if i_count[x-1] == n:
          fill[x-1] = 1
          #print(fill)
  A = i_count
  if sum(fill) == n:
    break
print(*A, end=' ')

Submission status: Wrong Answer

Solution code:
import sys

def main():
    input = sys.stdin.readline
    n, k = map(int, input().split())
    a = [int(x) for x in input().split()]
    key = 1
    nn = n
    while nn > 0.5:
        key += 1
        nn /= 2
    
    for _ in range(min([key, k])):
        b = [0]*n
        for i in range(n):
            l, r = max([i-a[i], 0]), min([i+a[i], n-1])
            b[l] += 1
            if r != n-1:
                b[r+1] -= 1
        for i in range(n):
            a[i] = 0
            a[i] += b[i]
            if i != 0:
                 a[i] += a[i-1]
    print(*a)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

def main():
    n,k= map(int,input().split())
    lamps = list(map(int,input().split()))

    lamps = np.array(lamps)
    # print(lamps)


    for i in range(k):
        result = np.array([0] * n)

        for j in range(n):
            tmp = np.array([0]*n)

            if j-lamps[j] < 0:
                tmp[0:j] = 1
            else:
                tmp[j - lamps[j]:j] = 1


            if j+lamps[j] > n:
                tmp[j:n] = 1
            else:
                tmp[j:j + lamps[j] + 1] = 1


            result += tmp
        lamps = result

    print(lamps)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import numpy as np

N, K = map(int, input().split())
An = list(map(int, input().split()))
finish = [N for i in range(N)]
print(finish)

#Sn = np.array([[0 for i in range(N)] for i in range(N)])
#for i in range(N):
#    Sn[i][max(0,i - An[i]): min(i + An[i] + 1, N)] = 1
#print(Sn)

thresh = np.array([[abs(i-j) for i in range(N)] for j in range(N)])

for i in range(K):
    buf = np.array(An-thresh)
    An = np.count_nonzero(buf >= 0, axis=1)
    #An = [sum((Ln<=i)&(i<=Hn)) for i in range(N)]
    if list(An) == finish:
        break
    
print(*list(An))

Submission status: Wrong Answer

Solution code:
import copy

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

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

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

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

# N, k = map(int, input().split())
# prev_arr = list(map(int, input().split()))

N = k = 200000
prev_arr = [0]*N

count = 0
for i in range(min(k, 3*int(math.log(N))+10)):
    arr = [0]*N
    for j in range(N):
        left = max(0, j-prev_arr[j])
        right = min(N-1, j+prev_arr[j])
        arr[left] += 1
        if right < N-1:
            arr[right+1] -= 1

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

    # print(arr)
    prev_arr = arr
    count += 1

# print(count)
print(*prev_arr)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import copy

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

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

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

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
if K <42:
    for q in range(K):
        foo = [1 for k in range(3*N+1)]
        for k in range(N):
            for j in range(1, A[k]+1):
                foo[k-j+N] +=1
                foo[k+j+N] +=1
        #print(foo)

        for k in range(N):
            A[k] = foo[k+N]
        print(A)
else:
    for k in range(N):
        A[k] = N
ans = ""
for k in range(len(A)):
    ans += str(A[k]) + " "

print(ans.rstrip())

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
life = [[0]*N]*N
#life = [[i==j for i in range(N)] for j in range(N)]
a = list(map(int,input().split()))
for k in range(K,50):
  life = [[-1*a[j]<=j-i and j-i<=a[j] for j in range(N)]for i in range(N)]
  #print(life)
  a = [sum(life[i]) for i in range(N)]
  #print(life[:][1])
  #print(a)
b=[str(i) for i in a]
b=" ".join(b)
print(b)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans1=[]
ans2=[]
ans1+=a
ans2+=a
for i in range(min(k,32)):
  now=0
  ans2=[]
  ans2+=ans1
  kans=[0]*n
  for j in range(n):
    if j+ans2[j]+1<=n-1:
      kans[j+ans2[j]+1]-=1
    now+=1+kans[j]
    #基本kans[j]は0だが終点は-1
    ans1[j]=now
  now=0
  kans=[0]*n
  for j in range(1,n+1):
    if n-j-ans2[n-j]>=0:
      kans[n-j-ans2[n-j]-1]-=1
    now+=1+kans[n-j]
    #基本kans[j]は0だが終点は-1
    ans1[n-j]+=now-1
  if ans1==[n-1]*n:
    for i in range(n):
      ans1[i]+=1
    break

print(*ans1)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

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

    for _ in range(min(30,K)):
        B = [0] * (N + 1)
        for i,a in enumerate(A):
            B[max(i - a,0)] += 1
            B[min(i + a + 1,N)] -= 1
        for i in range(N):
            B[i + 1] += B[i]
        A = B
    print(' '.join(map(str,A[:-1])))            
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from itertools import accumulate

def resolve():
    it = map(int, sys.stdin.read().split())
    N, K = next(it), next(it)
    A = [next(it) for i in range(N)]

    for k in range(K):
        B = [0]*(N+1)
        for i, di in enumerate(A):
            lhs = max(0, i-di)
            rhs = min(i+di+1, N)

            B[lhs] += 1
            B[rhs] -= 1

        if B[0] == N and B[-1] == N:
            print(*[N]*N)
            return
        A = accumulate(B)

    print(*A)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
a = list(map(int,input().split()))
for i in range(max(K,50)):
  if a == [N]*N:
    break
  temp = [0]*N
  for j in range(N):
    m = max(0,j-a[j])
    M = min(N-1,j+a[j])
    #print(j,m,M)
    for k in range(m,M+1):
      temp[k] += 1
  a = temp
b=[str(i) for i in a]
b=" ".join(b)
print(b)

Submission status: Wrong Answer

Solution code:
from math import log2

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(K):
  ans=[0]*N
  for j in range(N):
    num=A[j]
    for k in range(max([j-num,0]),min([j+num+1,N])):
      ans[k]+=1
    #print(ans,max([j-num,0]),min([j+num,N-1]))
  A=ans
  
  if K>math.log(N):
    break
print(' '.join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from itertools import accumulate

def resolve():
    it = map(int, sys.stdin.read().split())
    N, K = next(it), next(it)
    A = [next(it) for i in range(N)]

    for k in range(K):
        B = [0]*(N+1)
        for i, di in enumerate(A):
            lhs = max(0, i-di)
            rhs = min(i+di+1, N)

            B[lhs] += 1
            B[rhs] -= 1

        print(B)
        if B[0] == N and B[-1] == N:
            print(*[N]*N)
            return
        A = accumulate(B)

    print(*A)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

for j in range(50):
    s = [0] * (n + 1)
    for i in range(n):
        if i - a[i] >= 0:
            s[i - a[i]] += 1
        else:
            s[0] += 1
        if i + a[i] + 1 < n + 1:
            s[i + a[i] + 1] -= 1
        else:
            s[n] -= 1
            
    s_ = [0] * (n + 1)
    s_[0] = s[0]
    for i in range(n):
        s_[i + 1] = s_[i] + s[i + 1]
        
    a = s_
    
print(*s_[:n])

Submission status: Wrong Answer

Solution code:
import copy

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

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

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

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

Submission status: Wrong Answer

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

for i1 in range(40):
    B = [0 for i in range(N)]
    for i in range(N):
        for j in range(max(0,i-Lum[i]),min(i+Lum[i]+1,N)):
            B[j]+=1
    Lum = B

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

#Sn = np.array([[0 for i in range(N)] for i in range(N)])
#for i in range(N):
#    Sn[i][max(0,i - An[i]): min(i + An[i] + 1, N)] = 1
#print(Sn)

thresh = np.array([[abs(i-j) for i in range(N)] for j in range(N)])

for i in range(K):
    buf = np.array(An-thresh)
    An = np.count_nonzero(buf >= 0, axis=1)
    #An = [sum((Ln<=i)&(i<=Hn)) for i in range(N)]
    
print(An)

Submission status: Wrong Answer

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

for j in range(50):
    s = [0] * (n + 1)
    for i in range(n):
        if i - a[i] >= 0:
            s[i - a[i]] += 1
        else:
            s[0] += 1
        if i + a[i] + 1 < n + 1:
            s[i + a[i] + 1] -= 1
        else:
            s[n] -= 1
            
    s_ = [0] * (n + 1)
    s_[0] = s[0]
    for i in range(n):
        s_[i + 1] = s_[i] + s[i + 1]
        
    a = s_
    
print(*s_[:n])

Submission status: Wrong Answer

Solution code:
import math
import numpy as np

def action(A, N):
  B = np.array([0] * N)
  for i in range(N):
    s = math.ceil(i - A[i] - 0.5)
    e = math.ceil(i + A[i] + 0.5)
    if s < 0:
      s = 0
    if e > N:
      e = N
    B[s:e] += 1 
  return B

def main():
  N, K = map(int, input().split())
  A = np.array([int(s) for s in input().split()])

  for i in range(K):
    A = action(A, N)
    if A[0] == N & all(A):
      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()))
for i in range(min(k, 41)):
    b = [0]*n
    for j in range(n):
        for l in range(a[j]+1):
            if j >= l:
                b[j-l] += 1
            if n-1-j >= l:
                b[j+l] += 1
            if l == 0:
                b[j] -= 1
    a = b
print(a)

Submission status: Wrong Answer

Solution code:
NK = list(map(int,input().split()))
A = list(map(int,input().split()))
for k in range(NK[1]):
    d = [0]*NK[0]
    for i, v in enumerate(A):
        for j in range(i-v, i+v+1):
            if j>=0 and j<len(A):
                d[j]+=1

    for i in range(len(A)):
        A[i] = d[i]

print(A)

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
for k in range(math.ceil(math.log2(K)+1)):
    B = [0]*N
    for i in range(N):
        for j in range(max(i-A[i], 0), min(A[i]+i+1, N)):
            B[j] += 1
    A = B
print(A)

Submission status: Wrong Answer

Solution code:
n,k=[int(_) for _ in input().split()]
A=[int(_) for _ in input().split()]

for i in range(k):
    _A=[0 for i in range(n+1)]
    for j in range(n):
        _A[max(0,j-A[j])]+=1
        _A[min(n,j+A[j]+1)]-=1
    for j in range(1,n):
        _A[j]+=_A[j-1]
    if sum(_A)==n*n:
        break
    else:
        A=_A[:n]

print(A)

Submission status: Wrong Answer

Solution code:
import numpy as np


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


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

limit_count = int(np.log10(N))
for _ in range(limit_count):
    B = np.zeros(N, dtype="int")
    for i in range(N):
        end = np.minimum(coordinate[i]+A[i], N)
        start = np.maximum(coordinate[i]-A[i], 1)

        B[start-1:end] += 1
    A = B

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

Submission status: Wrong Answer

Solution code:
from math import log2

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N, K = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    for _ in range(41):
        cumsum = [0 for _ in range(N)]
        for i, a in enumerate(A):
            left = max(0, i - a)
            cumsum[left] += 1
            right = i + 1 + a
            if right <= N - 1:
                cumsum[right] -= 1
        for i in range(1, N):
            cumsum[i] += cumsum[i - 1]
        A = cumsum
    print(' '.join(map(str, A)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from itertools import accumulate

def resolve():
    it = map(int, sys.stdin.read().split())
    N, K = next(it), next(it)
    A = [next(it) for i in range(N)]

    for k in range(K):
        B = [0]*(N+1)
        for i, di in enumerate(A):
            lhs = max(0, i-di)
            rhs = min(i+di+1, N)

            B[lhs] += 1
            B[rhs] -= 1

        if B[0] == N:
            print(*[N]*N)
            return
        A = accumulate(B)

    print(*A)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
keep = a
for i in range(k):
    b = [0] * n
    for j in range(min(n, 100)):
        b[max(0, j - a[j]):min(n, j + a[j] + 1)] = map(lambda x: x + 1, b[max(0, j - a[j]):min(n, j + a[j] + 1)])
    a = b

print(' '.join([str(_) for _ in a[:n]]))

Submission status: Wrong Answer

Solution code:
import math
import numpy as np

def cal_B(a_list):
    b_list = np.zeros(N, dtype=int)
    for i in range(N):
        temp = np.zeros(N, dtype=int)
        min_x = max(math.ceil(i - a_list[i] - 0.5), 0)
        max_x = min(math.floor(i + a_list[i] + 0.5), N-1)
        
        temp[min_x : max_x+1] = 1
        b_list += temp
    return b_list

if __name__ == "__main__":
    N, K = map(int, input().split())
    A_list = np.array(list(map(int, input().split())))
    B_list = cal_B(A_list)

    for _ in range(100):
        B_list = cal_B(B_list)

    for i in range(N):
        print(B_list[i], end=" ")

Submission status: Wrong Answer

Solution code:
import math
import sys

N, K = map(int, input().split())
if K > 41:
  K = 41
A = list(map(int, input().split()))
A.insert(0, 0)
B = [0] * (N+1)
ans = [N] * N

def operation():
  global A, B, N
  for i in range(1, N+1):
    left = math.ceil(i - A[i] - 0.5)
    right = math.floor(i + A[i] + 0.5)
    if left < 1:
      left = 1
    if right > N:
      right = N
    for j in range(left, right+1):
      B[j] += 1


operation()

#print(A)
#print(B)

for _ in range(K):
  for i in range(1, N+1):
    if A[i] != B[i]:
      A[i] = B[i]
    B[i] = 0
  operation()
  if A == ans:
    print(ans)
    sys.exit()

print(A[1:])

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
*lumen, = list(map(int, input().split()))
lamps = [set() for i in range(n)]
num_of_lamps = [0] * n

for i in range(1, n+1):
    x_min = i - lumen[i-1]
    x_max = i + lumen[i-1]
    if x_min < 1:
        x_min = 1
    if x_max > n:
        x_max = n
    for j in range(x_min, x_max+1):
        num_of_lamps[j-1] += 1

for i in range(k):
    next_num_of_lamps = [0] * n

    for i in range(1, n+1):
        x_min = i - lumen[i-1]
        x_max = i + lumen[i-1]
        if x_min < 1:
            x_min = 1
        if x_max > n:
            x_max = n
        for j in range(x_min, x_max+1):
            next_num_of_lamps[j-1] += 1

    lumen = num_of_lamps
    num_of_lamps = next_num_of_lamps

lumen = ' '.join(list(map(str,lumen)))
print(lumen)

Submission status: Wrong Answer

Solution code:
n,k=[int(_) for _ in input().split()]
A=[int(_) for _ in input().split()]

for i in range(k):
    _A=[0 for i in range(n+1)]
    for j in range(n):
        _A[max(0,j-A[j])]+=1
        _A[min(n,j+A[j]+1)]-=1
    for j in range(1,n):
        _A[j]+=_A[j-1]
    if sum(_A)==n*k:
        break
    else:
        A=_A[:n]

print(A)