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 sys
import numpy as np

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, K = map(int, readline().split())
    np.set_printoptions(precision=0)
    A = np.array(readline().split(), np.int64)
    for _ in range(K):
        B = np.zeros(N + 1)
        for i, a in enumerate(A):
            B[max(0, int(i - a))] += 1
            B[min(int(i + a + 1), N)] -= 1
        A = B.cumsum()[:-1]
    print(*A)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]*n
cnt=0
while a[0]!=n and cnt<k:
  cnt+=1
  for i in range(n):
    b[max(0,i-a[i]):min(n,i+a[i]+1)]=map(lambda x:x+1,b[max(0,i-a[i]):min(n,i+a[i]+1)])
  a=b
  b=[0]*n
print(*a)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]*n
cnt=0
while a[0]!=n and cnt<k:
  cnt+=1
  for i in range(n):
    b[max(0,i-a[i]):min(n,i+a[i]+1)]=map(lambda x:x+1,b[max(0,i-a[i]):min(n,i+a[i]+1)])
  a=b
  b=[0]*n
print(a)

Submission status: Wrong Answer

Solution code:
import math
from itertools import accumulate
n, k = map(int, input().split())
As = list(map(int, input().split()))
_n = math.floor(math.log(n,2)) + 1
for i in range(min(_n, k)):
  _As = [0]*(n+1)
  for j in range(n):
    l = max(0, j - As[j])
    r = min(n - 1, j + As[j])
    _As[l] += 1
    _As[r+1] -= 1
  As = list(accumulate(_As))[:-1]
print(' '.join(list(map(lambda x:str(x),As))))

Submission status: Wrong Answer

Solution code:
import math
from itertools import accumulate
n, k = map(int, input().split())
As = list(map(int, input().split()))
_n = math.floor(math.log(n,2)) + 1
for i in range(min(_n, k)):
  _As = [0]*(n+1)
  for j in range(n):
    l = max(0, j - As[j])
    r = min(n - 1, j + As[j])
    _As[l] += 1
    _As[r+1] -= 1
  As = list(accumulate(_As))[:-1]
print(' '.join(map(lambda x:str(x),As)))

Submission status: Wrong Answer

Solution code:
import math
from itertools import accumulate
n, k = map(int, input().split())
As = list(map(int, input().split()))
_n = math.floor(n ** 0.5) + 1
for i in range(min(_n, k)):
  _As = [0]*(n+1)
  for j in range(n):
    l = max(0, j - As[j])
    r = min(n - 1, j + As[j])
    _As[l] += 1
    _As[r+1] -= 1
  As = list(accumulate(_As))[:-1]
print(As)

Submission status: Wrong Answer

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



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

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

Submission status: Wrong Answer

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

for k in range(K):
    for i in range(N):
        for j in range(N):
            if j-A[j]-0.5<= i <= j+A[j]+0.5:
                B[i]+=1
    A=B

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

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
A_list = list(map(int, input().split()))
for _ in range(math.ceil(math.log2(K)) + 1):
    count_list = [0] * N
    for i, v in enumerate(A_list):
        count_list[i - v if i - v > 0 else 0] += 1
        if i + v + 1 < N:
            count_list[i + v + 1] -= 1
    temp = 0
    for i in range(len(A_list)):
        temp += count_list[i]
        A_list[i] = temp

print(*A_list)

Submission status: Wrong Answer

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

for _ in range(min(K, 50)):
    lamp = [0 for i in range(N + 1)]
    for i in range(N):
        lamp[max(0, i - A[i])] += 1
        lamp[min(N, i + A[i] + 1)] -= 1

    print(lamp)
    for i in range(1, N + 1):
        lamp[i] += lamp[i - 1]
    A = lamp

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

Submission status: Wrong Answer

Solution code:
import numpy as np
from numba import njit

n, k = map(int, input().split())
arr = np.array(list(map(int, input().split())))


@njit
def solve(n, k, arr):
    for i in range(k):
        tmp_arr = np.zeros(n + 2, np.int64)
        for i, power in enumerate(arr):
            tmp_arr[max(0, i - power + 1)] += 1
            tmp_arr[min(n + 1, i + power + 2)] -= 1
        arr = np.cumsum(tmp_arr)[1:-1]
        if i > 40:
            return arr
    return arr


print(*solve(n, k, arr))

Submission status: Wrong Answer

Solution code:
import numpy as np
from numba import njit

n, k = map(int, input().split())
arr = np.array(list(map(int, input().split())))


@njit
def solve(n, k, arr):
    for i in range(k):
        tmp_arr = np.zeros(n + 1, np.int64)
        for i, x in enumerate(arr):
            tmp_arr[max(0, i - x)] += 1
            tmp_arr[min(n, i + x + 1)] -= 1
        arr = np.cumsum(tmp_arr)[:-1]
        if i > 40:
            return arr
    return arr


print(*solve(n, k, arr))

Submission status: Wrong Answer

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

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

for _ in range(min(20,k)):
    imos = [0]*(n+1)
    for i,a in enumerate(al):
        l = max(0,i-a)
        r = min(n,i+a+1)
        imos[l] += 1
        imos[r] -= 1
    new_al = []
    curr_val = 0
    for im in imos[:-1]:
        curr_val += im
        new_al.append(curr_val)
    al = new_al[:]

print(*al)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N,K=map(int,input().split())

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


for _ in range(K):
    ans=[0]*len(A)
    start=[0]*len(A)
    end=[0]*len(A)
    
    for index,item in enumerate(A):
        start[max(0,index-item)]+=1
        end[min(len(end)-1,index+item)]+=1
    
    #print(start)
    #print(end)
    
    temp=0
    for i in range(len(ans)):
        temp+=start[i]
        ans[i]=temp
        temp-=end[i]
    
    if len(list(set(A)))==1:
        break
    else:
        A=ans[:]

print(*ans)

Submission status: Wrong Answer

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

cnt = 0
for _ in range(k):
  if cnt >= 50:continue
  count = [0]*n
  for i in range(n):
    for j in range(-A[i],A[i]+1):
      if 0 <= i + j <= n-1:
        count[i+j] += 1
  A = count  
  cnt += 1

print(A)

Submission status: Wrong Answer

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

for _ in range(k<100):
  count = [0]*n
  for i in range(n):
    for j in range(-A[i],A[i]+1):
      if 0 <= i + j <= n-1:
        count[i+j] += 1
  A = count  

print(A)

Submission status: Wrong Answer

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

for _ in range(k):
  count = [0]*n
  for i in range(n):
    for j in range(-A[i],A[i]+1):
      if 0 <= i + j <= n-1:
        count[i+j] += 1
  A = count  

print(A)

Submission status: Wrong Answer

Solution code:
# 問題文の意味がわからんコンテスト
# 0の場合も自分自身を照らす、っての気づくところからやっと読解
# Kを5000兆回やったあとはすべての要素がNになっとる この収束はわりと早いらしい
n, k = map(int, input().split())
a = list(map(int, input().split()))

for _ in range(max(k, 100)):
    b = [0] * (n + 1)
    for i in range(n):
        b[max(0, i - a[i])] += 1
        b[min(n, i + a[i] + 1)] -= 1
    for i in range(n):
        b[i + 1] += b[i]
    a = b[:n]
print(" ".join(list(map(str, a))))

Submission status: Wrong Answer

Solution code:
# 問題文の意味がわからんコンテスト
# 0の場合も自分自身を照らす、っての気づくところからやっと読解
# Kを5000兆回やったあとはすべての要素がNになっとる この収束はわりと早いらしい
n, k = map(int, input().split())
a = list(map(int, input().split()))

for _ in range(50):
    b = [0] * (n + 1)
    for i in range(n):
        b[max(0, i - a[i])] += 1
        b[min(n, i + a[i] + 1)] -= 1
    for i in range(n):
        b[i + 1] += b[i]
    a = b[:n]
print(" ".join(list(map(str, a))))

Submission status: Wrong Answer

Solution code:
# 問題文の意味がわからんコンテスト
# 0の場合も自分自身を照らす、っての気づくところからやっと読解
# Kを5000兆回やったあとはすべての要素がNになっとる この収束はわりと早いらしい
n, k = map(int, input().split())
a = list(map(int, input().split()))

for _ in range(1000):
    b = [0] * (n + 1)
    for i in range(n):
        b[max(0, i - a[i])] += 1
        b[min(n, i + a[i] + 1)] -= 1
    for i in range(n):
        b[i + 1] += b[i]
    a = b[:n]
print(" ".join(list(map(str, a))))

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N, K = LI()
    A = LI()

    # 全部0の最遅ケースでもlog(N)*2くらいで収束する
    for _ in range(min(K, int(2 * math.log(N)) + 1)):
        tmp = [0] * (N + 1)
        b = [0] * (N + 1)
        for i in range(N):
            tmp[max(i - A[i], 0)] += 1
            tmp[min(i + A[i] + 1, N)] -= 1
        for i in range(N):
            b[i+1] = tmp[i] + b[i]
        for i in range(N):
            A[i] = b[i+1] 
        # print(A)

    print(*A)

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N, K = LI()
    A = LI()

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

    print(*A)

    if __name__ == '__main__':
        resolve()

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
B = []
for i in range(1, N+1):
  B.append(list(range(math.ceil(i - A[i-1] -0.5), math.ceil(i + A[i-1] + 0.5))))
A = [0] * N
for x in B:
  if 1 in x:
    A[0] += 1
  if 2 in x:
    A[1] += 1
  if 3 in x:
    A[2] += 1
  if 4 in x:
    A[3] += 1
  if 5 in x:
    A[4] += 1
if K >= 2:
  for i in range(K-1):
    for k in range(1, N+1):
      B[k-1] = list(range(math.ceil(k - A[k-1] -0.5), math.ceil(k + A[k-1] + 0.5)))
    A = [0] * N
    for x in B:
      if 1 in x:
        A[0] += 1
      if 2 in x:
        A[1] += 1
      if 3 in x:
        A[2] += 1
      if 4 in x:
        A[3] += 1
      if 5 in x:
        A[4] += 1
print(str(A[0]) + " " + str(A[1]) + " " + str(A[2]) + " " + str(A[3]) + " " + str(A[4]))

Submission status: Wrong Answer

Solution code:
import sys
n,k = map(int,input().split())
ls = list(map(int,input().split()))
if n <= k:
    print([n]*n)
    sys.exit()
for j in range(k):
    di = [0]*(n+1)
    for i in range(n):
        if i - ls[i] >= 0 and i + ls[i] <= n-1:
            di[i - ls[i]] += 1
            di[i + ls[i] + 1] -= 1
        elif i - ls[i] >= 0 and i + ls[i] > n-1:
            di[i - ls[i]] += 1
            di[n] -= 1
        elif i - ls[i] < 0 and i + ls[i] <= n-1:
            di[0] += 1
            di[i + ls[i] + 1] -= 1
        else:
            di[0] += 1
            di[n] -= 1
    fi = [0]*(n+1)
    fi[0] = di[0]
    for l in range(1,n+1):
        fi[l] = fi[l-1] + di[l]
    ls = fi
    if list(set(ls)) == [n]:
        break
print(*fi[:-1])

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
A=list(map(int,input().split()))
def loop(A):
    B=[0]*n
    for j in range(n):
        l=max(0,j-A[j])
        r=min(n-1,j+A[j])
        B[l]+=1
        if r<n-1:
            B[r+1]-=1
    for j in range(1,n):
        B[j]+=B[j-1]
    return A


for i in range(min(50,k)):
    A=loop(A)


print(*A)

Submission status: Wrong Answer

Solution code:
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    op = 0
    while True:
        new = [0 for _ in range(n + 1)]
        for i in range(n):
            new[max(0, i - a[i])] += 1
            new[min(n, i + a[i] + 1)] -= 1
        for i in range(1, n + 1):
            new[i] += new[i - 1]
        a = new[:-1]
        op += 1
        if op == k or len(set(a)) == 1:
            break
    print(" ".join(map(str, a)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    op = 0
    while op * op <= k:
        new = [0 for _ in range(n + 1)]
        for i in range(n):
            new[max(0, i - a[i])] += 1
            new[min(n, i + a[i] + 1)] -= 1
        for i in range(1, n + 1):
            new[i] += new[i - 1]
        a = new[:-1]
        op += 1
        if op >= k:
            break
    print(" ".join(map(str, a)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    op = 0
    while op * op <= k:
        new = [0 for _ in range(n + 1)]
        for i in range(n):
            new[max(0, i - a[i])] += 1
            new[min(n, i + a[i] + 1)] -= 1
        for i in range(1, n + 1):
            new[i] += new[i - 1]
        a = new[:-1]
        op += 1
    print(" ".join(map(str, a)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    op = 0
    while len(set(a)) > 1:
        new = [0 for _ in range(n + 1)]
        for i in range(n):
            new[max(0, i - a[i])] += 1
            new[min(n, i + a[i] + 1)] -= 1
        for i in range(1, n):
            new[i] += new[i - 1]
        a = new[:-1]
        op += 1
        if op >= k:
            break
    print(" ".join(map(str, a)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K = map(int, input().split())
A = np.array(list(map(int, input().split())))
print(A)
for cnt in range(K):
  B = np.zeros((N+1,), dtype = int)
  #print(B)
  for i in range(N):
    bright = int(A[i])
    l = max(i-bright,0)
    r = min(i+bright+1, N)
    B[l,] += 1
    B[r,] -= 1
  #print(B)
  B = np.cumsum(B)
      
  A = B[:-1]
  print(A)
  if np.min(A) == N:
    #print(cnt)
    break
    
print(" ".join(map(str,A)))

Submission status: Wrong Answer

Solution code:

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

x = X[:] + [0]
for _ in range(K):
    if all(v == N for v in x[:-1]):
        break

    new = [0] * (N + 1)
    for i in range(N):
        new[max(0, i - x[i])] += 1
        new[min(N, i + x[i] + 1)] -= 1

    for i in range(N):
        new[i + 1] += new[i]
    x = new[:]

print(*x)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
N, K = map(int, input().split())
A = list(map(int, input().split()))
if all([a == 0 for a in A]):
    print(*A)
    exit()
for k in range(min(50, K)):
    B = [0]*N
    for i in range(N):
        B[max(0, i-A[i])] += 1
        r = i+A[i]+1
        if r < N:
            B[r] -= 1
    A = list(accumulate(B))
print(*A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

import numpy as np
from numba import njit

N_ko, K_kai = map(int, input().split())
A_list = list(map(int, input().split()))
A = np.array(A_list, dtype=np.int64)

@njit
def cal_cumsum(A):
    Light_length = np.zeros(N_ko, dtype=np.int64)
    
    for i in range(N_ko):
        left = max(0, i - A[i])
        right = min(N_ko - 1, i + A[i])
        
        Light_length[left] += 1
        
        if (right + 1 < N_ko):
            Light_length[right + 1] -= 1
    
    Light_length = np.cumsum(Light_length)

    return(Light_length)

for k in range(min(42, K_kai)):
    A = cal_cumsum(A)


print(A)

Submission status: Wrong Answer

Solution code:
def main():
    N_ko, K_kai = map(int, input().split())
    init_light = list(map(int, input().split()))


    for k in range(max(50,K_kai)):
        light_list = [0 for i in range(N_ko)]

        for i in range(N_ko):
            left = max(0, i - init_light[i])
            right = min(N_ko - 1, i + init_light[i])
            
            light_list[left] += 1

            if (right + 1 < N_ko):
                light_list[right + 1] -= 1
            
        for i in range(1, N_ko):
            light_list[i] += light_list[i - 1]
        
        init_light = light_list

        judge = all([init_light[i] == N_ko for i in range(N_ko)])
        
        
        if (judge):
            break   
    
    print(' '.join(map(str,light_list)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n,k=map(int,input().split())
a=list(map(int,input().split()))
c=0
while True:
    b=[0]*n
    if c==k:
        break
    for i in range(n):
        l=max(i-a[i],0)
        r=min(n-1,i+a[i])
        b[l]+=1
        if r+1<n:
            b[r+1]-=1
    f=True
    if b[0]!=n:
        f=False
    for i in range(1,n):
        b[i]+=b[i-1]
        if b[i]!=n:
            f=False
    a=b
    c+=1
    if f:
        break
print(a)

Submission status: Wrong Answer

Solution code:
import math

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

issame = True
for i in range(1,N):
    if A[i-1] != A[i]:
        issame = False
if issame:
    for i in range(N):
        print(K, end=' ')

ans = [0] * (N+1)

for j in range(K):
    ans = [0] * (N+1)
    for i in range(N):
        L = max(0, i-A[i])
        R = min(N, i+A[i]+1)
        ans[L] += 1
        ans[R] -= 1
    for i in range(1, N+1):
        ans[i] += ans[i-1]
    issame = True
    for i in range(N):
        if i != 0:
            if ans[i-1] != ans[i]:
                issame = False
        A[i] = ans[i]
    if issame:
        break

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

Submission status: Wrong Answer

Solution code:
import math

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

issame = True
for i in range(1,N):
    if A[i-1] != A[i]:
        issame = False
if issame:
    for i in range(N):
        print(A[0] + K, end=' ')

ans = [0] * (N+1)

for j in range(K):
    ans = [0] * (N+1)
    for i in range(N):
        L = max(0, i-A[i])
        R = min(N, i+A[i]+1)
        ans[L] += 1
        ans[R] -= 1
    for i in range(1, N+1):
        ans[i] += ans[i-1]
    issame = True
    for i in range(N):
        if i != 0:
            if ans[i-1] != ans[i]:
                issame = False
        A[i] = ans[i]
    if issame:
        break

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

Submission status: Wrong Answer

Solution code:
import math

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

ans = [0] * (N+1)

for j in range(K):
    ans = [0] * (N+1)
    for i in range(N):
        L = max(0, i-A[i])
        R = min(N, i+A[i]+1)
        ans[L] += 1
        ans[R] -= 1
    for i in range(1, N+1):
        ans[i] += ans[i-1]
    issame = True
    for i in range(N):
        if i != 0:
            if ans[i-1] != ans[i]:
                issame = False
        A[i] = ans[i]
    if issame:
        break

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

Submission status: Wrong Answer

Solution code:
import math

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

ans = [0] * (N+1)

for j in range(0, min(K, int(math.log(N))+1)):
    ans = [0] * (N+1)
    for i in range(N):
        L = max(0, i-A[i])
        R = min(N, i+A[i]+1)
        ans[L] += 1
        ans[R] -= 1
    for i in range(1, N+1):
        ans[i] += ans[i-1]
    for i in range(N):
        A[i] = ans[i]

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

Submission status: Wrong Answer

Solution code:
import math

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

ans = [0] * (N+1)

for j in range(0, int(math.log(N))+1):
    ans = [0] * (N+1)
    for i in range(N):
        L = max(0, i-A[i])
        R = min(N, i+A[i]+1)
        ans[L] += 1
        ans[R] -= 1
    for i in range(1, N+1):
        ans[i] += ans[i-1]
    for i in range(N):
        A[i] = ans[i]

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

Submission status: Wrong Answer

Solution code:
import math

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

ans = [0] * (N+1)

for j in range(0, int(math.log(K))+1):
    ans = [0] * (N+1)
    for i in range(N):
        L = max(0, i-A[i])
        R = min(N, i+A[i]+1)
        ans[L] += 1
        ans[R] -= 1
    for i in range(1, N+1):
        ans[i] += ans[i-1]
    for i in range(N):
        A[i] = ans[i]

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

Submission status: Wrong Answer

Solution code:
def add_1(n):
    return n + 1

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

for n_chg in range(k):
    n_light = [0] * n
    for i in range(n):
        print(n_light)
        print('i: {}, a[i]:{}\n'.format(i,a[i]))
        for j in range(max(i-a[i],0), min(i+a[i],n-1) + 1):
            n_light[j] += 1
            # n_light[max(i-a[i],0):min(i+a[i],n-1)] += 1
    a = n_light
    print('-------------\n')

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):
    acc = [0 for j in range(n+1)]
    for j in range(n):
        acc[max(0, j - a[j])] += 1
        acc[min(n-1, j + a[j]) + 1] -= 1
    for j in range(n):
        acc[j+1] += acc[j]
    a = acc[:-1]
    if sum(a) == n * n:
        print("i")
        break
print(" ".join(map(str, a)))

Submission status: Wrong Answer

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

def imos(n,a):
  imos_l=[0]*n
  for i in range(n):
    l=max(i-a[i],0)
    r=min(i+a[i],n-1)
    imos_l[l]+=1
    if (r+1)!=n:
      imos_l[r+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)
  if len(set(a))==1:
    break

print(*a)

Submission status: Wrong Answer

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

for i in range(min(30, k)):
    DP = [0] * (n+1)
    for j in range(n):
        light = A[j]
        DP[max(0, j-light)] += 1
        DP[min(n, j+light+1)] -= 1

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

    A = DP[:-1]

print(*A)

Submission status: Wrong Answer

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

for i in range(min(25, k)):
    DP = [0] * (n+1)
    for j in range(n):
        light = A[j]
        DP[max(0, j-light)] += 1
        DP[min(n, j+light+1)] -= 1

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

    A = DP[:-1]

print(*A)

Submission status: Wrong Answer

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

for i in range(min(21, k)):
    DP = [0] * (n+1)
    for j in range(n):
        light = A[j]
        DP[max(0, j-light)] += 1
        DP[min(n, j+light+1)] -= 1

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

    A = DP[:-1]

print(*A)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import Fraction               # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79e+308
    # inf = 2 ** 63 - 1             # (for fast JIT compile in PyPy) 9.22e+18
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def isp():   return input().split()
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, k = mi()
    L = lmi()

    for _ in range(k):
        if min(L) == max(L):
            break
        imos = [0] * n
        for i in range(n):
            num = L[i]
            imos[max(0, i - num)] += 1
            if i + num + 1 <= n - 1:
                imos[i + num + 1] -= 1
        for i in range(1, n):
            imos[i] += imos[i-1]
        L = imos
    
    print(*L, sep=' ')



if __name__ == "__main__":
    main()