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:

def func():
    import numpy as np
    N,K=map(int,input().split())
    A= np.array(list(map(int,input().split())))
    new_A = A
    len_A=len(A)
    count_list = np.zeros(len_A, dtype = int)
    K_list=range(K)
    A_list=range(len_A)
    for i in K_list:
        for j in A_list:
            if(new_A[j]!=0):
                low_posi=j-new_A[j]
                if(low_posi<0):
                    low_posi=0
                high_posi = j+new_A[j]
                if(high_posi>len_A):
                    high_posi=len_A+1
                count_list[low_posi:high_posi] += 1
            else:
                count_list[j]+=1
        new_A=count_list
        count_list = np.zeros(len_A,dtype=int)
    for s in new_A:
        print(str(s)+" ", end ="")
    print("")
if __name__ == '__main__':
    func()

Submission status: Wrong Answer

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

for turn in range(k):
    status = [0] * n
    for x in range(n):
        for y in range(n):
            if x + 1 - a[x] - 0.5 < y + 1 and y + 1 < x + 1 + a[x] + 0.5:
                status[y] += 1
    a = status
print(a)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
from itertools import accumulate #list(accumulate(A))
import math
    
N, K = mi()
A = li()

#light = [0] * (N+2)
#A = [0] + A + [0]
#print(math.log(N, 2))

thre = 0
for i in range(N):
    if A[i] < i:
        thre = max(thre, i-A[i])

if K >= min(math.log(N, 2) + 1, thre):
        for i in range(N):
            print(N, '', end='')
        print()
        exit()


for i in range(K):
    new = [0] * (N+1)
    for j in range(N):
        new[max(j-A[j], 0)] += 1
        new[min(j+A[j]+1, N)] += -1
        #print(new)
    new = list(accumulate(new))
    A = new[:N]

for i in range(N):
    print(A[i], '', end='')
print()

Submission status: Wrong Answer

Solution code:
import copy

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


lux = [int(A[i]) for i in range(N)]

for i in range(K):
    tmp = copy.deepcopy(lux)
    for j in range(N):
        tmp[j] = len([1 for k in range(N) if abs(k - j) <= lux[k]])
    lux = copy.deepcopy(tmp)
print(lux)

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):
    for j in range(N):
        pl, mi = min(j + DP[i-1][j], N-1), max(j - DP[i-1][j], 0)
        for k in range(mi, pl+1, 1):
            DP[i][k] += 1
    if DP[i][0] == N & DP[i][N - 1] == N:
        print(" ".join(map(str, [N] * N)))
        sys.exit()

print(" ".join(map(str, DP[K])))

Submission status: Wrong Answer

Solution code:
from math import log2

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

if k > log2(n)*2:
    ans = [str(n)] * n
    print(" ".join(ans))
    exit()

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

    a = l[:]

    if min(a) == n:
        break

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

Submission status: Wrong Answer

Solution code:
import math
import numpy as np

def action(A):
  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

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

for i in range(K):
  A = action(A)
  
print(A)

Submission status: Wrong Answer

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

def imos(n,a,ban):
  imos_l=[0 for i in range(n)]

  for i in range(n):
    x=i
    x_left=max(x-a[i],0)
    x_right=min(x+a[i],n-1)

    imos_l[x_left]+=1 #適宜加算する値に変える
    if (x_right+1)!=n:
      imos_l[x_right+1]-=1 #適宜加算する値に変える

  b=[0]
  for i in range(1,n+1):
    b.append(imos_l[i-1]+b[i-1])

  return(b[1:])

for i in range(k):
  a=imos(n,a,i)

  if len(set(a))==1:
    break

print(*a)

Submission status: Wrong Answer

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


class RAQ():
    
    def __init__(self, size):
        """初期化"""
        self.size = size
        n = 2 ** ((size-1).bit_length())
        treesize = n * 2
        st = [0] * treesize
        self.st = st
        self.offset = len(st) // 2

    @classmethod
    def from_array(cls, a):
        st = cls(len(a))
        for i, x in enumerate(a):
            st.add(i, i+1, x)
        return st

    def _add_topdown(self, a, b, value, k=1, l=0, r=-1):
        """区間[a, b) に対する加算
        k: 着目しているノード (1-indexed)
        l: 探索区間 st[l, r) の左端 (0-indexed)
        r: 探索区間 st[l, r) の右端 (0-indexed)
        """
        if r == -1:
            r = self.offset
        if r <= a or b <= l:
            return
        if l == r - 1:
            self.st[k] += value
            return
        if a <= l and r <= b:
            self.st[k] += value
            return
        mid = (l + r) // 2
        self._add(a, b, value, k * 2, l, mid)
        self._add(a, b, value, k * 2 + 1, mid, r)

    def _add_bottomup(self, a, b, value):
        """区間[a, b) に対する加算
        """
        a += self.offset
        b += self.offset - 1
        while a < b:
            if a & 1:
                self.st[a] += value
                a += 1
            a >>= 1
            if not b & 1:
                self.st[b] += value
                b -= 1
            b >>= 1
        if a == b:
            self.st[a] += value

    def add(self, a, b, value):
        """区間[a, b) に対する加算"""
        if a > b:
            raise ValueError("a must be less than equal b.")
        return self._add_bottomup(a, b, value)

    def get(self, key):
        """値の取得"""
        offset = len(self.st) // 2
        k = offset + key
        v = self.st[k]
        k >>= 1
        while k > 0:
            v += self.st[k]
            k >>= 1
        return v


def read():
    N, K = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    return N, K, A


def solve(N, K, A):
    if K > math.log2(N):
        print(' '.join([str(N)] * N))
        return
    raq = RAQ.from_array(A)
    a = [0 for i in range(N)]
    for k in range(K):
        for i in range(N):
            a[i] = raq.get(i)
        for i in range(N):
            raq.add(i, i+1, -a[i])
            l = max(0, i-a[i])
            r = min(N, i+1+a[i])
            raq.add(l, r, 1)
    print(' '.join([str(raq.get(i)) for i in range(N)]))


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Wrong Answer

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


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
        for j in range(N):
            if startIndex <= j and j <= endIndex:
                B[j] = B[j] + 1
    A = B
print(A)

Submission status: Wrong Answer

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

for x in range(K):
    light = [0 for x in range(N)]
    for i, lamp_power in enumerate(lamp_list):
        lower = i - lamp_power
        if lower < 0:
            lower = 0
        higher = i + lamp_power + 1
        if higher > N:
            higher = N
        # print(f"lower:{lower} high:{higher}")
        for j in range(lower, higher):
            light[j] += 1
        # print(f"i:{i} pow{lamp_power}")
        # print(light)
    lamp_list = light

print(lamp_list)

Submission status: Wrong Answer

Solution code:
# C - Lamps
from math import log2
import numpy as np
N,K = map(int,input().split())
A = list(map(int,input().split()))
if K>=20 or 2**(K-1)>=N:
    for i in range(N):
        print(N,end=' ')
    print('\n')
else:
    A = np.array(A,dtype=int)
    for k in range(K):
        new_A = np.zeros(N,dtype=int)
        for i in range(N):
            s = max(0,i-A[i])
            t = min(N,i+A[i]+1)
            new_A[s:t] += np.ones(t-s,dtype=int)
        A = new_A
    for i in range(N):
        print(A[i],end=' ')
    print('\n')

Submission status: Wrong Answer

Solution code:
NK = input().split()
N = int(NK[0])
K = int(NK[1])

A = [int(i) for i in input().split()]

result_list = [0 for i in range(N)]

for i in range(K):
  for a_i in range(len(A)):
    p = A[a_i]
    x = a_i - p
    y = a_i + p
    if(x < 0):
      x =0
    if(y > len(A)):
      y = len(A) - 1
    
    for j in range(y - x):
      result_list[j] += 1

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
#print(0,A)
for i in range(K):
    A_temp=[0]*N
    #print(A_temp)
    for j in range(N):
        #print(max(0,j-A[j]-1))
        #print(min(N-1,j+A[j]+1))
        if A[j]>0:
            for k in range(max(0,j-A[j]-1),min(N-1,j+A[j]+1)+1):
                A_temp[k] +=1
    A=A_temp
    #print(i,A)
print(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)
B = np.array([0]*len(A))

for i in range(K):
  B *=0
  for j in range(len(A)):
    llim = max([0, j-A[j]])
    ulim = min([len(A), j+A[j]+1])
    print(i, j, llim, ulim, A, B)
    B[llim:ulim] = B[llim:ulim] + 1
  A=B+0

print(*A)

Submission status: Wrong Answer

Solution code:
import numpy as np
n, k = map(int, input().split())
array = list(map(int, input().split()))
array = np.array(array)
Array = np.array([0]*n)
print(array)
print(Array)
def plusone(n):
    return n + 1

for j in range(k):
    for i in range(n):
        ai = array[i]
        Array[max(i-ai, 0):min(i+ai+1,n+1)] = Array[max(i-ai, 0):min(i+ai+1,n+1)] + 1
        if j == k - 1:
            answer = Array
    array = Array
    Array = np.array([0]*n)

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

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
import numpy as np

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N, K = LI()
A = LI()

"""
明るさが一定値を超えると計算しなくて良い
一定？d > math.floort(N/2)
"""

lamps = [[0] * N] * (K + 1)
lamps[0] = A

if A == [0] * N:
    A = map(str, A)
    print(" ".join(A))
    sys.exit()

lamps = np.array(lamps)

if K > 20:
    b = [str(N)] * N
    print("".join(b))
    sys.exit()
for i in range(K):
    for j in range(N):
        if max(0, j - lamps[i][j]) == min(N + 1, j + lamps[i][j]):
            lamps[i + 1][j] += 1
        else:
            lamps[i + 1][max(0, j - lamps[i][j]):min(N + 1, j + lamps[i][j]) + 1] += 1
            
ans = lamps[-1].tolist()
ans = map(str, ans)
print(" ".join(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy
import math
def main():
    N, K = map(int, input().split())
    a = [float(i) for i in input().split()]
    A = [0] * (N + 1)
    if K >= N:
        for i in range(1, N+1):
            A[i] = N
        print(A[1:])
        sys.exit()
    for i in range(1, N+1):
        A[i] = a[i - 1]
    for _ in range(K):
        count = [0] * (N + 1)
        for i in range(1, N+1):
            if A[i] == N:
                left_d = 1
                right_d = N
            else:
                left_d = math.ceil(i - A[i] - 0.5)
                right_d =  math.floor(i + A[i] + 0.5)
                if left_d < 1:
                    left_d = 1
                if right_d > N:
                    right_d = N
            for j in range(left_d, right_d+1):
                count[j] += 1
        A = copy.copy(count)
        flag = True
        for i in range(1, N+1):
            if A[i] != N:
                flag = False
                break
        if flag:
            break
    print(A[1:])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import copy
n,k = (int(x) for x in input().split())
la = list(map(int, input().split()))
for i in range(k):
  ans = [0]*n
  for j in range(n):
    s = max(0, j-la[j])
    e = min(n, j+la[j])
    ans[s:e+1] = [x+1 for x in ans[s:e+1]] 
  if min(ans)==n:
    break
  la = copy.copy(ans)
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    zeros=[0 for i in range(n)]
    if max(a)==0:
        print(*a)
        exit()
    if min(a)==n:
        print(*a)
        exit()
    if n<k:
        for i in range(n):
            print(n,end=" ")
        exit()
    for i in range(k):
        x=zeros.copy()
        for j in range(n):
            if a[j]==0:
                l=j
                r=j+1
            else:
                l=max(0,j-a[j])
                r=j+a[j]+1
        #    print(l,r)
            x[l]+=1
            if r+1<=n:
                x[r]+=-1
        ruiseki=[0]*n
        ruiseki[0]=x[0]
        a[0]=ruiseki[0]
        for i in range(1,n):
            ruiseki[i]=ruiseki[i-1]+x[i]
            a[i]=ruiseki[i]
    #  print(*ruiseki)
    print(*a)
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
from itertools import accumulate
from math import log2
def input(): return sys.stdin.readline().strip()

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

    if log2(N) <= K - 1:
        ans = [N] * N
        print(" ".join(map(str, ans)))
        return
    
    for _ in range(K):
        B = [0] * (N + 1)
        for i in range(N):
            head = max(i - A[i], 0)
            tail = min(i + A[i] + 1, N)
            B[head] += 1
            B[tail] -= 1
        A = list(accumulate(B))[:N]
    print(" ".join(map(str, A)))
    

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(K):
  An = [0 for ii in range(len(A))]
  for j in range(N):
    range_min = max(0, math.ceil(j - A0[j] - 0.5))
    range_max = min(N-1, math.floor(j + A0[j] + 0.5))
    for k in range(range_max - range_min + 1):
      An[range_min + k] = An[range_min + k] + 1
  A0 = An    
  
print(An)

Submission status: Wrong Answer

Solution code:
#import numpy as np
import sys
# import copy


def xnxn(n=0, flag="v"):
    """
    args:
        int n: a number of lows to read
    example:
        input   1
        retrun  1

        input   1 2 3
        return  [1,2,3]
        input   1 2 3
                4 
        return  [[1,2,3],
                [4]]
    """
    if n == 0:
        temp = list(map(int, input().split()))
        if len(temp) == 1:
            if flag == "l":
                return temp
            else:
                return temp[0]
        elif len(temp) > 1:
            return temp
    else:
        temp = [list(map(int, input().split())) for _ in range(n)]
        return temp


n, k = xnxn()
a = xnxn(flag="l")
a = [1] + a
for _ in range(k):
    add = [0 for _ in range(n+1)]
    for i in range(1, n + 1):
        idx_min = max(1, i - a[i])
        idx_max = min(n, i + a[i])
        for t in range(idx_min, idx_max + 1):
            add[t] = add[t]+1

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

Submission status: Wrong Answer

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


def calc_imos(arr):
    imos = [0] * (N + 1)
    for i, a in enumerate(arr):
        l = max(0, i - a)
        r = min(N - 1, i + a)
        imos[l] += 1
        imos[r + 1] -= 1
    imos = list(accumulate(imos))
    return imos[:-1]


A = calc_imos(A)
K -= 1
if K == 0:
    print(*A, sep=' ')
    exit()

A = calc_imos(A)
K -= 1
if K == 0:
    print(*A, sep=' ')
    exit()

A = calc_imos(A)
K -= 1
if K == 0:
    print(*A, sep=' ')
    exit()


for i in range(N):
    A[i] = min(N, A[i] + K + 1)
print(*A, sep=' ')

Submission status: Wrong Answer

Solution code:
import copy

a1 = input().split()
a2 = input().split()

N = int(a1[0])
K = int(a1[1])

Aout = [int(a2[i]) for i in range(N)]
#Aout = map((lambda x: int(x)), a2)
print(Aout)

for i in range(K):
	Ain = copy.deepcopy(Aout)
	Aout = [0] * N
	for j in range(N):
		for k in range(N):
			if abs(j -k) < Ain[j] +0.5:
				Aout[k] += 1
for i in range(N):
	print(str(Aout[i]), end=' ')

Submission status: Wrong Answer

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

#照らす範囲のリストを取得して1加算していく
def solve(li):
  new_li = [0]*n
  for i in range(len(li)):
    new_li[max(i - li[i], 0):(i + 1 + li[i])]=[i+1 for i in new_li[max(i - li[i], 0):(i + 1 + li[i])]]
  return new_li

for i in range(k):
  data = solve(data)

print(data)

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):
    for j in range(N):
        pl, mi = min(j + DP[i-1][j], N-1), max(j - DP[i-1][j], 0)
        for k in range(mi, pl+1, 1):
            DP[i][k] += 1
    if DP[i][0] == N & DP[i][N - 1] == N:
        print(" ".join(map(str, [N] * N)))
        sys.exit()

print(" ".join(map(str, DP[K])))

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==1:
    print(1)
    exit()
if K >= N-1:
    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 i-a <0:
            start = 0
        end = i+a+1
        if i+a+1 <=N-1:
            nextgen[end] += -1
            end = N-1
        # print(start,end)
        nextgen[start] += 1
        # print(nextgen)
    dp = 0
    for i in range(N):
        dp += nextgen[i]
        A[i] = dp
    if A[1:N] == [N]*(N-1):
        break
print(A)

Submission status: Wrong Answer

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

def henkan(A,N):
    ANS=[0]*N
    for i in range(N):
        for j in range(1,A[i]+1):
            if i+j<=N-1:
                ANS[i+j]+=1
            else:
                break
        for k in range(1,A[i]+1):
            if i-k>=0:
                ANS[i-k]+=1
            else:
                break
        ANS[i]+=1
    return ANS

if K>=N:
    print([N]*N)
else:
    for i in range(K):
        A=henkan(A,N)
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())))

for i in range(k):
    next_a = np.array([0 for _ in range(n)])
    for j in range(n):
        next_a[max(j - a[j], 0):min(j + a[j] + 1, n)] += 1
    a = next_a
    print(' '.join(list(map(str, a.tolist()))))

Submission status: Wrong Answer

Solution code:
from math import log2

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

if k > log2(n)+10:
    ans = [str(n)] * n
    print(" ".join(ans))
    exit()

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

    a = l[:]

    if min(a) == n:
        break

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=a.copy()
zeros=[0 for i in range(n)]
if max(a)==0:
    print(*a)
    exit()
if min(a)==n:
    print(*a)
    exit()
if n<k:
    for i in range(n):
        print(n,end=" ")
    exit()
for i in range(k):
    x=zeros.copy()
    for j in range(n):
        if a[j]==0:
            l=j
            r=j+1
        else:
            l=max(0,j-a[j])
            r=j+a[j]+1
    #    print(l,r)
        x[l]+=1
        if r+1<=n:
            x[r]+=-1
    ruiseki=[0]*n
    ruiseki[0]=x[0]
    a[0]=ruiseki[0]
    for i in range(1,n):
        ruiseki[i]=ruiseki[i-1]+x[i]
        a[i]=ruiseki[i]
    print(*ruiseki)

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
A = list(map(int, input().split()))
endA = [N]*N
for i in range(K):
    if A == endA:
        break
    else:
        newA = [0]*N
        for j in range(N):
            for k in range(2*A[j]+1):
                if 0<=j-A[j]+k and j-A[j]+k <N:
                    newA[j-A[j]+k] += 1
        A = newA
print(A)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split())) # list()でリスト化、それを変数に代入。


for i in range(k):
    b = [0]*n
    for j in range(n):
        for l in range(max(0,j-a[j]), min(n, j+a[j]+1)):
            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()))
if N < K*3:
    for i in range(N-1):
        print(N, end=' ')
    print(N)
else:
    for k in range(K):
        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 = map(int,input().split())
a = list(map(int,input().split()))
flag = 0
light = [0]*n
if k >= n:
    for i in range(n):
        print(n,end=' ')
        exit()
for i in range(k):
    light = [0]*n
    for j in range(n):
        light[j] += 1
        for x in range(a[j]):
            try:
                if j - (x+1) < 0:continue
                light[j-(x+1)] += 1
            except IndexError:
                pass
            try:
                if j + (x+1) < 0:continue
                light[j+x+1] += 1
            except IndexError:
                pass
    if len(set(light)) == 1:
        break
    a = light
for i in range(n):
    print(light[i],end=' ')

Submission status: Wrong Answer

Solution code:
from math import log2

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

if k > log2(n)+5:
    ans = [str(n)] * n
    print(" ".join(ans))
    exit()

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

    a = l[:]

    if min(a) == n:
        break

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

Submission status: Wrong Answer

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

def henkan(A,N):
    ANS=[0]*N
    for i in range(N):
        ANS[i]+=1
        for j in range(1,A[i]+1):
            if i+j<=N-1:
                ANS[i+j]+=1
            else:
                break
        for k in range(1,A[i]+1):
            if i-k>=0:
                ANS[i-k]+=1
            else:
                break
    return ANS

if K>=N:
    print([N]*N)
else:
    for i in range(K):
        A=henkan(A,N)
print(A)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))
for k in range(k):
    d = []
    for i in range(n):
         d.extend(list(range(int(i - a[i]), int(i + a[i] + 1))))
    print(d)
    c = []
    c = Counter(d)
    print(c)
    for j in c.keys():
        if j >= 0 and j < len(a):
            a[j] = c[j]

print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ANS = [0 for n in range(N)]

for k in range(K):
  S = [0 for n in range(N)]
  for i in range(N):
    start = i - A[i]
    end = i + A[i] + 1
    if start < 0:
      start = 0
    if end > N:
      end = N
    for j in range(start, end):
      S[j] += 1
  ANS = [ANS[l]+S[l] for l in range(N)]
  A = S
print(S)

Submission status: Wrong Answer

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


def calc_imos(arr):
    imos = [0] * (N + 1)
    for i, a in enumerate(arr):
        l = max(0, i - a)
        r = min(N - 1, i + a)
        imos[l] += 1
        imos[r + 1] -= 1
    imos = list(accumulate(imos))
    return imos[:-1]


A = calc_imos(A)
K -= 1
if K == 0:
    print(*A, sep=' ')
    exit()

A = calc_imos(A)
K -= 1
if K == 0:
    print(*A, sep=' ')
    exit()

A = calc_imos(A)
K -= 1
if K == 0:
    print(*A, sep=' ')
    exit()


for i in range(N):
    A[i] = min(N, A[i] + K)
print(*A, sep=' ')

Submission status: Wrong Answer

Solution code:
import math

input1 = list(map(int, input().split()))
A = list(map(int, input().split()))

N = input1[0]
K = input1[1]

for k in range(K):
    B = [0] * N
    for i in range(1, N + 1):
        l_min = i - A[i - 1] - 0.5
        l_max = i + A[i - 1] + 0.5
        for j in range(max(1, math.floor(l_min)), min(math.floor(l_max) + 1, N + 1)):
            if(j >= l_min and j <= l_max):
                B[j - 1] += 1
    
    for x in range(N):
        A[x] = B[x]

print(A)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a_l = list(map(int,input().split()))
li_range = [[] for i in range(n)]

for i in range(n):
    li_range[i] = [i+1-a_l[i]-0.5,i+1+a_l[i]+0.5]

#ここまでででO(n)

for k in range(k):
    count_li = [0]*n
    for i in range(n):
        for j in range(n):
            if li_range[j][0]<i+1<li_range[j][1]:
                
                count_li[i]+=1
    for i in range(n):
        li_range[i] = [i+1-count_li[i]-0.5,i+1+count_li[i]+0.5]

print(count_li)

Submission status: Wrong Answer

Solution code:
import copy as cp
n,k = map(int,input().split())
lamps = list(map(int,input().split()))
# print(lamps)
lamp_io = [0]*n
# print(lamp_io)
for j in range(k):
    for i in range(len(lamps)):
        if(i == 0):
            for k in range(1,lamps[i]+1):
                if(i+k <= n-1):
                    lamp_io[k] += 1
                else:
                    break
            lamp_io[i] += 1
        elif(i == n-1):
            for k in range(1,lamps[i]+1):
                if(i-k >= 0):
                    lamp_io[i-k] += 1
                else:
                    break
            lamp_io[i] += 1
        else:
            for k in range(1,lamps[i]+1):
                a = 0
                b = 0
                if(i+k <= n-1):
                    lamp_io[i+k] += 1
                else:
                    a = 1
                if(i-k >= 0):
                    lamp_io[i-k] += 1
                else:
                    b = 1
                if(a == 1 and b == 1):
                    break
            lamp_io[i] += 1
        # print(lamp_io)    
    lamps = cp.copy(lamp_io)
    lamp_io = [0]*n
print(lamps)

Submission status: Wrong Answer

Solution code:
import numpy as np
def resolve():
    N, K = [int(i) for i in input().split()]
    A_list = [int(i) for i in input().split()]
    if N <= K:
        print([N] * N)
        return
    for i in range(K):
        light_list = [0] * N
        for j in range(len(A_list)):
            for k in range(-A_list[j], A_list[j]+1):
                light_list += np.eye(1, N, k=j+k, dtype=int)
        # import ipdb; ipdb.set_trace()
        A_list = light_list.reshape(N)
    print(" ".join([str(A) for A in A_list]))

resolve()