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:
n, k = map(int,input().split())
li = list(map(int,input().split()))

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

    for j in range(n):
        x = li[j]
        now[max(0,j-x)] += 1
        if j+x+1 < n:
            now[j+x+1] -= 1
    
    for j in range(n-1):
        now[j+1] += now[j]

    li = now
    if min(li) >= n-1:
        break

print(i)
for j in range(n):
    li[j] += (n-1)*(k-1-i)

print(*li)

Submission status: Wrong Answer

Solution code:

n, k = map(int, input().split())
a = list(map(int, input().split()))
current = a[:]
for _ in range(k):
    next = [1]*n
    stack = 0
    for j, v in enumerate(current):
        next[j] += int(str(stack)[-1])
        stack = str(stack)
        stack = stack[:len(stack)-1]
        if len(stack):
            stack = int(stack)
        else:
            stack = 0
        if v > 0:
            stack += int('1'*v)
    stack = 0
    for j in range(n-1, -1, -1):
        next[j] += int(str(stack)[-1])
        stack = str(stack)
        stack = stack[:len(stack) - 1]
        if len(stack):
            stack = int(stack)
        else:
            stack = 0
        if current[j] > 0:
            stack += int('1' * current[j])
    current = next
print(*current)

Submission status: Wrong Answer

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

if any(A) != 0 & N<=K:
    ans = [str(N)]*N
    print(' '.join(ans))
    exit()

light = [0]*N
last_light = A
for j in range(K):
    for i in range(N):
        if i-last_light[i] < 0:
            start = 0
        else:
            start = i-last_light[i]
        if i+last_light[i] > N:
            last = N
        else:
            last = i+last_light[i]
        light = light[:start] + list(map(lambda x:x+1,light[start:last+1])) + light[last+1:]
    last_light = copy.copy(light)
    light = [0]*N

for i in range(N):
    last_light[i] = str(last_light[i])
print(' '.join(last_light))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [0]*len(A)
n_max = 2*10**5
for _ in range(K):
  for i in range(N):
    if A[i] > N:
      continue
    for j in range(max(0, i-A[i]), min(len(B), i+A[i]+1)):
      B[j]+=1
  A = B.copy()
  B = [0] * len(A)
print(A)

Submission status: Wrong Answer

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

if k < n-2:
  for kk in range(k):
    hikari = [0]*n
    for i in range(n):
      for j in range(i+1-a[i],i+1+a[i]+1):
        if 0 < j and j < n+1:
          hikari[j-1] += 1
    a = hikari
else:
  a = [n-1]*n

for i in range(n-1):
  print(str(a[i])+" ",end="")
print(a[n-2])

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率

def input(): return sys.stdin.readline()[:-1]
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]

class BIT():#添字は1から始まることに注意
    def __init__(self, max_n):
        self.size = max_n + 1
        self.tree = [0] * self.size
        self.depth = self.size.bit_length()
        
    def initialize(self,seq):
        tree = self.tree
        size = self.size
        for i,x in enumerate(seq,1):
            tree[i] += x
            j = i+(i&(-i))
            if j < size:
                tree[j] += tree[i]
        
    def __repr__(self):
        return self.tree.__repr__()
        
    def get_sum(self,i):
        tree = self.tree
        s = 0
        while i:
            s += tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        tree = self.tree
        size = self.size
        while i < size:
            tree[i] += x
            i += i & -i
    
    def find_kth_element(self,k):#k番目（最小は１）の要素
        tree = self.tree; size = self.size
        x,sx = 0,0
        dx = 1 << (self.depth)
        for i in range(self.depth - 1, -1, -1):
            dx = (1 << i)
            if x + dx >= size:
                continue
            y = x + dx
            sy = sx + tree[y]
            if sy < k:
                x,sx = y,sy
        return x + 1
 
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, K = map(int, input().split())
    A = list(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    bit=[0]*(N+2)
    for i,a in enumerate(A):
        i+=1
        left=max(i-a,0)
        right=min(i+a+1,N+1)
        bit[left]+=1
        bit[right]-=1
    
    for k in range(K):
        update=[0]*N
        nA=copy(A)
        ax=accumulate(bit)
        #print(bit)
        #next(ax)
        next(ax)
        for i in range(N):
            a=A[i]
            na=next(ax)
            print(na)

            if a!=na:
                nA[i]=na
                update[i]=1


        #print(A)
        if sum(update)==0:
            break

        for i, a in enumerate(A):
            if update[i]==0:
                continue
            na=nA[i]
            i+=1

            left=max(i-a,0)
            right=min(i+a+1,N+1)
            bit[left]-=1
            bit[right]+=1
            left=max(i-na,0)
            right=min(i+na+1,N+1)
            bit[left]+=1
            bit[right]-=1

        A=nA
    
    print(*nA)

        





if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

for j in range(k):
    b = [0]*n
    for i in range(n):
        if i-a[i]>0:
            start = i-a[i]
        else:
            start = 0
        if i+a[i]>n-1:
            end = n
        else:
            end = i+a[i]
        for l in range(start,end):
            b[l] += 1
    a = b


print(*a)

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
A = list(map(int,input().split()))
ans_list = list()
for k in range(K):
  for i in range(N):
    count = 1
    for j in range(N):
      if j > i and j+1 - A[j] - 0.5 <= i +1 :
        count += 1
      elif i > j and  i + 1  <= j+1  + A[j] + 0.5:
        count += 1
    ans_list.append(count)
  A = tuple(ans_list)
  ans_list.clear()
  
print(A)

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]*n
  cnt=0
  for j in range(n):
    if a[j]>=max(n-j,j):
      cnt+=1
  if cnt==n:
    for j in range(n):
      a[j]=(k-i)*n
    break
  for j in range(n):
    for m in range(j-a[j],j+a[j]+1):
      if 0<=m<=n-1:
        b[m]=b[m]+1
  a=b
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()))
import math
if K >= math.log2(N):
    A = [N]*N
else:
    for _ in range(K):
        B = A
        A = [0]*N
        for i in range(N):
            a = B[i]
            L = range(max(0, i-a), min(N, i+a+1))
            for j in L:
                A[j] += 1
print(' '.join(map(str, A)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
f=0
limit=[n]*n
while f<k:
    b=[0]*n
    for i in range(n):
        for j in range(i-a[i],i+a[i]+1):
            if 0<=j<=n-1:
                b[j]+=1
    a=b
    f+=1
    if a==limit:
        break
print(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 i in range(k):
  for j in range(n):
    B[j]=0
    d=A[j]
    mi=j-d
    ma=j+d
    if mi<=0:
      mi=0
    if ma>=n:
      ma=n-1
    while mi<=ma:
      B[mi]=B[mi]+1
      mi=mi+1
  A=B
for i in range(int(len(A))):
  print(A[i],end="")
  if i!=int(len(A)):
    print(" ",end="")

Submission status: Wrong Answer

Solution code:
import sys

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

n, k, *a = map(int, read().split())

for _ in range(k):
    b = [0] * n
    for i in range(n):
        d = a[i]
        for j in range(i-d, i+d+1):
            if j < 0 or j >= n:
                continue
            b[j] += 1
    
    a = b

print(b)

Submission status: Wrong Answer

Solution code:
def resolve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    lis = [N]*N
    if K > N:
        print(*lis)
resolve()

Submission status: Wrong Answer

Solution code:
import copy as cp

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

threshold = 20

if K>threshold:
    A = [N]*N
else:
    for i in range(K):
        A_old = cp.deepcopy(A)
        A = [0]*N
        for j in range(N):
            elem = A_old[j]
            start = max(j-elem,0)
            end = min(j + elem + 1,N)
            for k in range(start, end):
                A[k] += 1
                
print(*A)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
list = list(map(int, input().split()))
rlist=[]
i=0
l=len(list)
while(i<K):
  j=0
  while(j<l):
    k=0
    max=1
    while(k<l):
      if(k < j):
        if(j<=k+list[k]):
          max+=1
      elif(j < k):
        if(k-list[k]<=j):
          max+=1
      k+=1
    rlist.append(max)
    j+=1
  list=rlist
  rlist=[]
  i+=1
print(list)

Submission status: Wrong Answer

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

# for i in range(k):  
#     for j in range(n):
B = [0 for i in range(n)]        
if A == B:
    print(' '.join(map(str, A)))
    sys.exit()

for r in range(k):
    B = [0 for i in range(n)] 
    for i in range(n):
        d_min = max(0, i - A[i])
        d_max = min(n-1, i + A[i])
        for j in range(d_min, d_max+1):
            B[j] += 1
    A = B
    if A[0] == n and A[n-1] == n:
        break
print(' '.join(map(str, A)))

Submission status: Wrong Answer

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

if k>=n:
    ans=[n]*n
    print(*ans)
    exit()

for _ in range(k):
    b=[0]*n
    for i in range(n):
        q=a[i]
        for j in range(i-q,i+q+1):
            if 0<=j<=n-1:
                b[j]+=1
    a=b[:]
    t2=time.time()
    if t2-t1>1.500:
        print(*a)
        exit()
print(*a)

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
a = list(map(int, input().split()))
tnp = 1
for i in range(k-1):
    tnp = tnp*2
    if tnp > n:
        ans = [n]*n
        print(*ans)
        exit()
for i in range(k):
    b = [0]*n
    for i in range(n):
        l = i-a[i]
        r = i+a[i]
        #print(l,r)
        b[max(l,0)] += 1
        if (r<n-1):
            b[r+1] -= 1
        #print(b)
    
    for i in range(1,n):
        b[i] = b[i-1] + b[i]
    a = b
print(*b)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
a=list(map(int,input().split()))
if 2**(k-1)>=n:
    for i in range(n):
        print(n,end='')
        print(' ',end='')
else:
    for _ in range(k):
        sub=[0]*n
        for i in range(n):
            sub[max(0,i-a[i])]+=1
            if i+a[i]<n-1:
                sub[i+a[i]+1]-=1
        for i in range(1,n):
            sub[i]=sub[i]+sub[i-1]
        a=sub
    for i in sub:
        print(i,end='')
        print(' ',end='')

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = A
tmp = [0] * N
for i in range(K):
    for index, j in enumerate(ans):
        for k in range(index - j, index + j + 1):
            if(0 <= k and k < N):
                tmp[k] = tmp[k] + 1

    ans = tmp
    tmp = [0] * N

print(ans)

Submission status: Wrong Answer

Solution code:
import math


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

    for i in range(k):
        a = solve(a)
        # print(" ".join([str(i) for i in a]))
        for i in a:
            if i != n:
                break
        else:
            return a
    return a


def solve(a):
    b = [0 for i in range(len(a))]

    for i, a_i in enumerate(a):
        print("({}, {})".format(max(0, math.ceil(i - a_i - 0.5)), min(len(b), int(i + a_i + 0.5) + 1)))
        for j in range(max(0, math.ceil(i - a_i - 0.5)), min(len(b), int(i + a_i + 0.5) + 1)):
            b[j] += 1
    return b


if __name__ == '__main__':
    result = main()
    print(" ".join([str(i) for i in result]))

Submission status: Wrong Answer

Solution code:

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

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

#n = 2 * 10 ** 5
#a = [0] * n
cnt = 0

while cnt < k:
    imos = [0] * (n + 1)
    for i in range(n):
        imos[max(i - a[i], 0)] += 1
        imos[min(i + a[i] + 1, n)] -= 1
    for i in range(n):
        imos[i + 1] += imos[i]
    a = imos[0:n]
    cnt += 1
    if max(a) == n:
        break
print(*a)

Submission status: Wrong Answer

Solution code:
n,k=list(map(int,input().split()))
A=list(map(int,input().split()))
def sousa(a,k):
  B=[0]*len(a)
  for i in range(len(a)):
    for j in range(i-a[i],i+a[i]+1):
      if j>=0 and j<len(a):
        B[j]+=1
  k-=1
  return B if k==0 else sousa(B,k)
print(sousa(A,k))

Submission status: Wrong Answer

Solution code:

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

def light_change(A,N,K):
    for _ in range(K):
        B=[0 for _ in range(N)]
        for i in range(N):
            for j in range(max(0,i-A[i]),min(N,i+A[i]+1)):
                B[j]+=1
        A=B
    return A
  
print(light_change(A,N,K))

Submission status: Wrong Answer

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

n, k = map(int, input().split())
a = list(map(int, input().split()))
# A = 0, 0, 0, ..., 0でも最小値は2^(N-1)で増える
# k > 20くらいでnを超えるのでそれくらいまで考えればよい
def print_ans(ans):
   ans = list(map(lambda x: str(x) if x <= n else str(n), ans))
   print(" ".join(ans))

all_max = [n] * n
if k > 30:
   print_ans(all_max)
   exit()

# k < 20の時はimos法でO(N*k)くらいで求まりそう

for _ in range(k):
   pre_a = a[:]
   imos = [0 for _ in range(n+1)]
   for i in range(n):
      l = max(0, i - pre_a[i])
      r = min(n, i + pre_a[i] + 1)
      imos[l] += 1
      imos[r] -= 1
   # process
   v = 0
   for i in range(n):
      v += imos[i]
      if v > n:
         v = n
      a[i] = v
print_ans(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()))
if 2**k>=n:
    for i in range(n):
        print(n,end='')
        print(' ',end='')
else:
    for _ in range(k):
        sub=[0]*n
        for i in range(n):
            sub[max(0,i-a[i])]+=1
            if i+a[i]<n-1:
                sub[i+a[i]+1]-=1
        for i in range(1,n):
            sub[i]=sub[i]+sub[i-1]
        a=sub
    for i in sub:
        print(i,end='')
        print(' ',end='')

Submission status: Wrong Answer

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

for k in range(K):
    B = [0]*N
    for i in range(N):
        B[i] = 0
        for j in range(N):
            if A[j] >= abs(j-i):
                B[i] = B[i]+1
    A = B

print(A)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
if a==[0]*n:
    print(*a)
else:
    for i in range(k):
        b=[0]*n
        for j in range(n):
            count=1
            for l in range(1,j):
                if l+a[l-1]+0.5>=j:
                    count+=1
            for l in range(j+1,n+1):
                if l-a[l-1]<=j:
                    count+=1
            b[j-1]=count
        a=b
        if a==[n]*n:
            print(*a)
            exit() 
    print(*a)

Submission status: Wrong Answer

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

if N > 40:
  print(*[N for _ in range(N)])
  quit()

def f(A):
    table = [0]*(N+1)
    for i, v in enumerate(A):
        d = A[i]
        table[max(0, i-d)] += 1
        table[min(N, i+d+1)] -= 1

    cumsum = [table[0]]
    for i in range(1, N):
        cumsum.append(cumsum[-1]+table[i])
    return cumsum

for i in range(K):
    A = f(A)
print(*A)

Submission status: Wrong Answer

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

n, k = map(int, input().split())
a = list(map(int, input().split()))
# A = 0, 0, 0, ..., 0でも最小値は2^(N-1)で増える
# k > 20くらいでnを超えるのでそれくらいまで考えればよい
def print_ans(ans):
   ans = list(map(lambda x: str(x) if x <= n else str(n), ans))
   print(" ".join(ans))

all_max = [n] * n
if k > 20:
   print_ans(all_max)
   exit()

# k < 20の時はimos法でO(N*k)くらいで求まりそう

for _ in range(k):
   pre_a = a[:]
   imos = [0 for _ in range(n+1)]
   for i in range(n):
      l = max(0, i - pre_a[i])
      r = min(n, i + pre_a[i] + 1)
      imos[l] += 1
      imos[r] -= 1
   # process
   v = 0
   for i in range(n):
      v += imos[i]
      if v > n:
         v = n
      a[i] = v
print_ans(a)

Submission status: Wrong Answer

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

if n<=k:
    print([n]*n)

Submission status: Wrong Answer

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

if k>=n:
    ans=[n]*n
    print(*ans)
    exit()

for _ in range(k+10**10):
    b=[0]*n
    for i in range(n):
        q=a[i]
        for j in range(i-q,i+q+1):
            if 0<=j<=n-1:
                b[j]+=1
    a=b[:]
    t2=time.time()
    if t2-t1>1.800:
        print(*a)
        exit()
print(*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):
		ans[_]+=1



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

cnt=0
while cnt<k:
	ans=[0]*n
	for i in range(n):
		#print("old:",a)
		blight(a[i],i)
		#print(ans)
		#print("new:",a)
	cnt+=1
	a=copy.deepcopy(ans)
print(ans)

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.int64)

loop_cnt = 0
while loop_cnt < k:
    if all([a[i] >= max(i, n - 1 - i) for i in range(n)]):
        break

    new_a = np.zeros(n, dtype=np.int64)

    for j in range(n):
        new_a[max(0, j - a[j]): min(n, j + a[j] + 1)] += 1

    a = new_a
    loop_cnt += 1

a += k * (n - 1)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

n, k = map(int, input().split())
a = list(map(int, input().split()))
# A = 0, 0, 0, ..., 0でも最小値は2^(N-1)で増える
# k > 20くらいでnを超えるのでそれくらいまで考えればよい
def print_ans(ans):
   ans = list(map(lambda x: str(x) if x <= n else str(n), ans))
   print(" ".join(ans))

all_max = [n] * n
if k > 20:
   print_ans(all_max)

# k < 20の時はimos法でO(N*k)くらいで求まりそう

for _ in range(k):
   pre_a = a[:]
   imos = [0 for _ in range(n+1)]
   for i in range(n):
      l = max(0, i - pre_a[i])
      r = min(n, i + pre_a[i] + 1)
      imos[l] += 1
      imos[r] -= 1
   # process
   v = 0
   for i in range(n):
      v += imos[i]
      if v > n:
         v = n
      a[i] = v
print_ans(a)

Submission status: Wrong Answer

Solution code:
def plus(x):
    return x+1

n,k=map(int,input().split())
A=list(map(int,input().split()))
for j in range(k):
    B=[0]*n
    for i in range(n):
        B=B[0:max(0,i-A[i])]+list(map(plus,B[max(0,i-A[i]):min(n,i+A[i]+1)]))+B[min(n,i+A[i]+1):n]
    A=B.copy()
print(B)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
a=list(map(int,input().split()))
import math
x=math.log2(n+1)
x=math.floor(x)
if k>=x:
    for i in range(n):
        print(n,end='')
        print(' ',end='')
else:
    for _ in range(k):
        sub=[0]*n
        for i in range(n):
            sub[max(0,i-a[i])]+=1
            if i+a[i]<n-1:
                sub[i+a[i]+1]-=1
        for i in range(1,n):
            sub[i]=sub[i]+sub[i-1]
        a=sub
    for i in sub:
        print(i,end='')
        print(' ',end='')

Submission status: Wrong Answer

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

for i in range(k):
    tmpa = a[:]
    b = [0] * 5
    for j in range(5):
        for k in range(-tmpa[j], tmpa[j] + 1):
            if 0 <= j + k <= 4:
                b[j + k] += 1
    a = b[:]
    if sum(a) == n ** 2:
        break

print(*b)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=[0]*len(a)
for l in range(k):
    ans=[0]*len(a)
    for i in range(len(a)):
        left=0
        right=0
        if a[i]==0:
            ans[i]+=1
        else:
            left=i-a[i]
            right=i+a[i]
            if left<=0:
                left=0
            if len(a)-1<right:
                right=len(a)-1
            for j in range(left,right+1):
                ans[j]+=1
    a=ans
print(ans)

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 = 10
    nn = n
    while nn > 0:
        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:
import copy
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=[0]*N
for k in range(K):
    for i in range(N):
        count = 0
        for j in range(N):
            if A[j] >= abs(j - i):
                count += 1
        B[i] = count
    A=copy.copy(B)
print(A)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
f=0
while f<k:
    b=[0]*n
    for i in range(n):
        for j in range(i-a[i],i+a[i]+1):
            if 0<=j<=n-1:
                b[j]+=1
    a=b
    f+=1
print(a)

Submission status: Wrong Answer

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

for i in range(k):
    r = [0] * n
    for j in range(n):
        for d in range(a[j] * 2 + 1):
            p = j - a[j] + d
            if p >= 0 and p < n:
                r[p] += 1    
    a = r
    
print(a)

Submission status: Wrong Answer

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

for i in range(k):
  for j in range(n):
    for r in range(j-a[j], j+a[j]+1):
      if(0<=r and r<n):
        b[r] += 1
  a = b[:]
  print(a)
  if(min(a) == n):
    break
  b = [0 for _ in range(n)]
  
ans = ""
for i in range(n):
  ans += str(a[i]) + " "
print(ans[:-1])

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = input().split()#string
A = list(map(int, A))
B = [0 for i in range(N)]
for i in range(K):
  for j in range(N):
    tmp_low = j - A[j] 
    tmp_high = j + A[j] 
    if tmp_low <= 0:
      tmp_low = 0
    if tmp_high >= N-1:
      tmp_high = N-1
    for k in range(tmp_low, tmp_high+1, 1):
      B[k] = B[k] + 1
  A = B
print(' '.join(map(str, A)))

Submission status: Wrong Answer

Solution code:
import copy

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

for k in range(K):
    B = [0 for _ in range(N)]
    for i in range(1, N+1):
        left = max(i-A[i-1], 1)
        right = min(i+A[i-1], N)
        for j in range(left, right+1):
            B[j-1]+=1
    A = copy.deepcopy(B)
print(A)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ans = np.array(A, np.int8)
for i in range(K):
  k = np.array([0]*N, np.int8)
  for n in range(N):
    #print(max(0, n - ans[n]), min(N, n + ans[n]))
    k[max(0, n - ans[n]):min(N, n + ans[n])+1] += 1
  ans = k
  
for i in  ans:
  print(min(i, N))

Submission status: Wrong Answer

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

dp = [[0]*N for _ in range(K+1)]
for i in range(N):
    dp[0][i] = S[i]

for i in range(K):
    for j in range(N):
        m = max(0, j-dp[i][j])
        M = min(N, j+dp[i][j]+1)
        for k in range(m, M):
            dp[i+1][k] += 1
for i in range(K+1):
    print(" ".join(map(str, dp[i])))

Submission status: Wrong Answer

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

for _ in range(K):
  ans = [0 for _ in range(N)]
  for n in range(N):
    temp = [0 for _ in range(N)]
    start = n-A[n]
    end = n+A[n]+1
    if start < 0:
      start = 0
    if end > N:
      end = N
    temp[start:end] = [1] * (end-start)
    ans = np.array(ans)+ np.array(temp)
  A = ans.tolist()
print(A)

Submission status: Wrong Answer

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

for _ in range(K):
  B= [0 for _ in range(N)]
  C=0
  for i in A:
    for j in range(C-i,C+i+1):
      try:
        if(j>=0):
          B[j]+=1
      except:
        pass
    C+=1
  A = copy.copy(B)
  
print(B)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
a = list(map(int, input().split()))
print(a[0])
b = []

for k in range(K):
    b = [0 for _ in range(N)]
    for i in range(N):
        if i - a[i] >= 0:
            start = i - a[i]
        else:
            start = 0
        if i+a[i] < N:
            end = i + a[i] + 1
        else:
            end = N
        for j in range(start, end):
            b[j] += 1
        
    a = b

ans = ""
for i in range(N):
    ans += str(a[i])
    if i != N-1:
        ans += " "
print(ans)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd, floor
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np

N, K = MAP()
A = LIST()

cnt = 0
while 1:
	a = [0]*(N+1)
	flg = 1
	for i in range(N):
		a[max(0, i-A[i])] += 1
		a[min(N, i+A[i]+1)] -= 1
		if max(0, i-A[i]) == 0 and min(N, i+A[i]+1) == N:
			flg *= 1
		else:
			flg *= 0
	A = list(accumulate(a))
	cnt += 1
	if cnt == K:
		print(*A[:-1])
		exit()
	if flg:
		break

A = [x+N*(K-cnt) for x in A]
print(*A[:-1])

Submission status: Wrong Answer

Solution code:
N,K =map(int,input().split())
A=list(map(int,input().split()))
def light_change(A,N):
    B=[0 for _ in range(N)]
    for i in range(len(A)):
        for j in range(max(0,i-A[i]),min(N,i+A[i]+1)):
            B[j]+=1
    return B
  
for _ in range(K):
  A=light_change(A,N)
print(A)

Submission status: Wrong Answer

Solution code:
n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
for _ in range(k):
    new_a = [0]*n
    for i, v in enumerate(a):
        for j in range(i-v, i+v+1):
            if 0<=j<n:
                new_a[j] += 1
    #print(a)
    a = new_a
print(a)

Submission status: Wrong Answer

Solution code:
import sys
n,k=map(int,input().split())
a =list(map(int,input().split()))
if k>=n:
    print(*([n]*n))
    sys.exit