Problem:


Score : 500 points

Problem Statement

We have N bulbs arranged on a number line, numbered 1 to N from left to right.
Bulb i is at coordinate i.

Each bulb has a non-negative integer parameter called intensity.
When there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5.
Initially, the intensity of Bulb i is A_i. We will now do the following operation K times in a row:

For each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i.

Find the intensity of each bulb after the K operations.

Constraints

1 \leq N \leq 2 \times 10^5

1 \leq K \leq 2 \times 10^5

0 \leq A_i \leq N

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 \ldots A_N

Output

Print the intensity A{'}_i of each bulb i after the K operations to Standard Output in the following format:

A{'}_1 A{'}_2 \ldots A{'}_N

Sample Input 1

5 1
1 0 0 1 0

Sample Output 1

1 2 2 1 2 

Initially, only Bulb 1 illuminates coordinate 1, so the intensity of Bulb 1 becomes 1 after the operation.
Similarly, the bulbs initially illuminating coordinate 2 are Bulb 1 and 2, so the intensity of Bulb 2 becomes 2.

Sample Input 2

5 2
1 0 0 1 0

Sample Output 2

3 3 4 4 3 



Sample input:
5 1
1 0 0 1 0


Sample output:
1 2 2 1 2

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K=map(int,input().split())
A= 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)
check_A = np.array([N]*N)
for i in range(42):
    for j in A_list:
        if(new_A[j]!=0):
            low_posi=max(0,j-new_A[j])
            high_posi=min(len_A,j+new_A[j])
            count_list[low_posi:high_posi+1] += 1
        else:
            count_list[j]+=1
    new_A=count_list
    count_list = np.zeros(len_A,dtype=int)
    if(np.allclose(new_A,check_A)):
        for s in new_A:
            print(str(s)+" ", end ="")
        exit()

for s in new_A:
  print(str(s)+" ", end ="")
print("")

Submission status: Wrong Answer

Solution code:
import numpy as np


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


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

limit_count = np.log10(N)
for j in range(int(limit_count)):
    for i in range(N):
        c = coordinate[i]
        B[i] = (A >= np.abs(coordinate - c)).sum()
    A = B.copy()


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

Submission status: Wrong Answer

Solution code:
from math import log2

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
class Range_BIT:
    def __init__(self, n):
        self.n = n
        self.bit0 = [0]*(n+1)
        self.bit1 = [0]*(n+1)
    
    def _Add(self, k, x, is_bit0=True):
        if is_bit0 == True:
            data = self.bit0
        else:
            data = self.bit1
        while k <= self.n:
            data[k] += x
            k += k & -k
    
    def _Get(self, data, k):
        s = 0
        while k:
            s += data[k]
            k -= k&-k
        return s
    
    """ 配列の獲得 """
    def Array(self):
        array = [0]*(n+1)
        for i in range(self.n):
            array[i] = self.Get(i+1,i+2)
        return array[:-1]
    
    """ 区間[l:r)に対してxを加算 """
    def Add(self, l, r, x):
        self._Add(l, -x*(l-1), is_bit0=True)
        self._Add(r, x*(r-1), is_bit0=True)
        self._Add(l, x, is_bit0=False)
        self._Add(r, -x, is_bit0=False)
    
    """ 区間[l:r)の総和 """
    def Get(self, l, r):
        Pi = self._Get(self.bit1, r-1)*(r-1) - self._Get(self.bit1, l-1)*(l-1)
        Qi = self._Get(self.bit0, r-1) - self._Get(self.bit0, l-1)
        return Pi+Qi

n,k = map(int,input().split())
A = list(map(int,input().split()))
for j in range(50):
    if j==0:
        rbit = Range_BIT(n)
        for i,a in enumerate(A):
            rbit.Add(max(1,i+1-a), min(i+2+a, n+1), 1)
    else:
        A_ = rbit.Array()
        rbit = Range_BIT(n)
        for i,a in enumerate(A_):
            rbit.Add(max(1,i+1-a), min(i+2+a, n+1), 1)
print(*rbit.Array())

Submission status: Wrong Answer

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

print(*ans1)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
li = list(map(int,input().split()))
ans = [0]*n
tmp = [0]*n
#print(ans)
#[0, 0, 0, 0, 0]
for kkk in range(100):
    for i,l in enumerate(li):
        for xx in range(n):
            sa = abs(xx - i)
            #print(sa,l,'sa',i)
            if sa<=l:
                tmp[xx]+=1
    ans = tmp
    li = tmp
    tmp = [0]*n
    if len(set(ans)) == 1:
        break
print(*ans)

Submission status: Wrong Answer

Solution code:
import math
from collections import defaultdict

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


def left_right(x, d):
    left = x - d - 0.5
    right = x + d + 0.5
    return left, right

printed = set()
printed_lst = []
bl = []
for x in range(100):
    dic = defaultdict(int)
    for i in range(N):
        l, r = left_right(i + 1, al[i])
        left = math.ceil(l)
        if left == 0:
            left += 1
        right = math.floor(r)
        for n in range(left, right + 1):
            dic[n] += 1
    al = list(dic.values())[:N]
    bl = [str(i) for i in al]
    bls = ''.join(bl)
    printed.add(bls)
    printed_lst.append(bls)
    if len(printed) != len(printed_lst):
        s = printed_lst.index(bls)
        s2 = x
        amari = (K-s)%(s2-s)
        ans = printed_lst[s+amari]
        print(ans)
        exit()

print(' '.join(bl))

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

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

sousa=0
kaisuu=max(K,42)

while sousa<kaisuu:
    for i in range(N):
        ma=i+A[i]+1
        if ma>N:
            ma=N
        mi=i-A[i]
        if mi<0:
            mi=0
        for j in range(mi,ma):
            B[j]+=1
    A=list(B)
    B=[0]*N
    sousa+=1

A=[str(k) for k in A]
print(" ".join(A))

Submission status: Wrong Answer

Solution code:
from math import log2
def main():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    for i in range(int(log2(N))):
        B = [0]*N
        for j in range(N):
            l = max(0,j-A[j])
            r = min(N-1,j+A[j])
            B[l:r+1] = map(lambda x:x+1, B[l:r+1])
        A = B
    print(*A)

main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import copy
n,k = map(int,input().split())

L = list(map(int,input().split()))
#Lt = copy.copy(L)
if k > 41:
    k=41
for i in range(k):
    Lt = [0 for i in range(n)]
    for j in range(n):
        
        if L[j] > 0:
            for m in range(1,L[j]+1):
                if j-m>=0:
                    Lt[j-m] += 1
                if j+m<=n-1:
                    Lt[j+m] += 1
        Lt[j] += 1
        #print(Lt)
    L = copy.copy(Lt)
    print(L)
print(' '.join(map(str,L)))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
current = a[:]
for _ in range(min(50, k)):
    next = [1]*n
    stack = 0
    for j, v in enumerate(current):
        next[j] += stack % 10
        stack //= 10
        if v > 0:
            stack += int('1'*v)
    stack = 0
    for j in range(n-1, -1, -1):
        next[j] += stack % 10
        stack //= 10
        if current[j] > 0:
            stack += int('1' * current[j])
    current = next
print(*current)

Submission status: Wrong Answer

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

def main():
    N, K = map(int, input().split())
    LampList = list(map(int, input().split()))
    
    if math.log(N) <= K:
        LampList = [N for i in range(N)]
        for i in range(N):
            print(LampList[i], end=' ')
    else:
        for i in range(K):
            tmpList = [0 for i in range(N)]
            for p in range(N):
                Start = p - LampList[p]
                Stop = p + LampList[p] + 1
                if Start < 0:
                    Start = 0
                if Stop > N:
                    Stop = N
                for q in range(Start, Stop):
                    tmpList[q] += 1
            
            LampList = tmpList
            if all(elem == N for elem in LampList):
                break
        
        for i in range(N):
            print(LampList[i], end=' ')
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

# = int(input())
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
length = len(A)
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

if K > N//2 + 1:
    L=[str(length) for a in range(N)]
    L=" ".join(L)
    print(L)
    exit()
else:
    for i in range(41):
        count = 0
        zero = np.array([0]*N)
        for j in range(N//2):
            if A[j] >= length-(j+1):
                zero += 1
            else:
                count += 1
                if j + A[j] + 1 >= length:
                    zero[j:] += 1
                else:
                    zero[j:A[j]+j+1] += 1
                if j - A[j] - 1 < 0:
                    zero[:j] += 1
                else:
                    zero[j-A[j]:j] += 1
        for j in range(N//2, N):
            if A[j] >= j:
                zero += 1
            else:
                count += 1
                if j + A[j] + 1 >= length:
                    zero[j:] += 1
                else:
                    zero[j:A[j]+j+1] += 1
                if j - A[j] - 1 < 0:
                    zero[:j] += 1
                else:
                    zero[j-A[j]:j] += 1
        if count == 0:
            break
        else:
            A = zero

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

Submission status: Wrong Answer

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

A = list(map(int,input().split()))
for i in range(42):
    B = [0]*N
    for j in range(N):
        if A[j] > 0:
            start = j - A[j]
            stop = j + A[j] + 1
            if start < 0:
                start = 0
            if stop > N:
                stop = N
            for k in range(start,stop):
                    B[k] += 1
        else:
            B[j] += 1
    A = B

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

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
A = list(map(int,input().split()))
for _ in range(k):
    c = [0]*n
    for i,j in enumerate(A):
        for k in range(i-j,i+j+1):
            if 0 <= k <= n-1:
                c[k] += 1
    if A == c:
        break
    A = c
    print(A)
print(" ".join(map(str,A)))

Submission status: Wrong Answer

Solution code:
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
import numpy as np

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,k=map(int, readline().rstrip().split())
    arr=list(map(int, readline().rstrip().split()))
    for _ in range(k):
        tmp=[0]*n
        for i in range(n):
            x = i - arr[i]
            y = i + arr[i] + 1
            if x<0:
                x=0
            if y<n:
                tmp[y]-=1
            tmp[x]+=1
        sm=tmp[0]
        arr[0]=tmp[0]
        for i in range(1,n):
            arr[i]=arr[i-1]+tmp[i]
            sm+=tmp[i]
        if tmp[0]==n and sm==n:
            break
    print(" ".join(map(str,arr)))
    return

Submission status: Wrong Answer

Solution code:
import math


N,K=map(int,input().split())
A=list(map(int,input().split()))
A.insert(0,0)
Atemp=[0 for i in range(len(A))]
#print(Atemp)
flag=1

for i in range(min(41,K)):
    for j in range(1,len(A)):
        if A[j]==0:
            continue
        start=max(1,j-A[j])
        end=min(len(A),j+A[j]+1)
        for k in range(start,end):
            Atemp[k]+=1

    """
    for l in range(1,int(len(A)/2)):

        if Atemp[l]>abs(len(A)-l):
            flag*=1
        else:
            flag*=0

    for l in range(int(len(A)/2),len(A)):
        if Atemp[l]>l:
            flag*=1
        else:
            flag*=0

    """

    A=Atemp.copy()
    Atemp = [0 for p in range(len(A))]
    """
    if flag==1:
        for o in range(1,len(A)):
            A[o]+=(K-i+1)*len(A)
            print(o)
        break
    flag=1
    """
    print(A)
for m in range(1,len(A)):
    print(A[m],end=" ")

Submission status: Wrong Answer

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

for _ in range(k):
    b = [0] * n
    for idx_a, val in enumerate(a):
        for j in range(idx_a, idx_a + val + 1):
            if j <= n - 1:
                b[j] += 1
        for m in range(idx_a - 1, idx_a - val - 1, -1):
            if m >= 0:
                b[m] += 1
    a = b

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

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 j in range(k):
    if j > 41:
        break

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

    for i, x in enumerate(a):
        new_a[i-x if i-x >= 0 else 0:i+x + 1] += 1
    
    print(new_a)
    a = new_a

print(*a)

Submission status: Wrong Answer

Solution code:
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    n, k = ZZ()
    A = ZZ()+[0]

    for _ in range(k):
        if A[0] >= n: break
        nA = [0] * (n+1)
        for i in range(n):
            nA[max(0, i-A[i])] += 1
            nA[min(n, i+1+A[i])] -= 1
        for i in range(1, n+1): nA[i] += nA[i-1]
        A = nA
    print(*A[:-1])

    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))

n, k = rm()
a = rl()
k = min(k, 40)
if n <= k:
    for _ in range(n):
        print(n, end=' ')
    exit()
for _ in range(k):
    li = [0] * n
    for i in range(n):
      s = max(i - a[i], 0)
      e = min(i + a[i], n-1)
      for m in range(s, e+1):
        li[m] += 1
for v in a:
    print(v, end=' ')

Submission status: Wrong Answer

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

t = [0 for _ in range(n + 1)]

def lightup(x, light):
    global t
    t[x] += 1

    for d in range(1, light + 1):
        dplus = x + d
        dminus = x - d
        if (dplus < n+1):
            t[dplus] += 1

        if (dminus > 0):
            t[dminus] += 1

for _ in range(k):
    for i in range(1, n + 1):
        lightup(i, a[i])

    a = list(t)
    t = [0 for _ in range(n + 1)]

a.pop(0)
print(a)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
if K >= 41:
    for i in range(N):
        print(N, end=' ')
    print('')
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()))

# for _ in range(k):
#     next_a = [0] * n
#     for i, brightness in enumerate(a):
#         begin = max(0, i - brightness)
#         end = min(i + brightness + 1, n)
#         for j in range(begin, end):
#             next_a[j] += 1
#     print(next_a)
#     a = next_a.copy()
print(a)
for t in range(k):
    print(t)
    finish = True
    stack = []
    for i, brightness in enumerate(a):
        if brightness != n:
            finish = False
        begin = i - brightness - 0.5
        end = i + brightness + 0.5
        stack.append((begin, "IN"))
        stack.append((end, "OUT"))
    if finish:
        break
    stack.sort(key=lambda x: x[0])
    now = 0
    pos = 0
    for inout in stack:
        if pos > n-1:
            break
        while pos < inout[0]:
            if pos > n-1:
                break
            a[pos] = now
            pos += 1
        if inout[1] == "IN":
            now += 1
        elif inout[1] == "OUT":
            now -= 1
    print(a)
print(*a, sep=" ")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=0
aa=[]
for i in range(n):
    for j in range(n):
        if j-a[j]-0.5<=i and j+a[j]+0.5>=i:
            b+=1
        elif j-a[j]-0.5>i:
            break
    aa.append(b)
    b=0
    # print(i,*a)
print(*aa)

Submission status: Wrong Answer

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

B = []
for i in range(N):
    if A[i] > 0:
        B.append(set([i]))
    else:
        B.append(set())
A = B

for k in range(K):
    # k個隣りとk+1個となりを見る
    B = []
    for i in range(N):
        s = set([])
        p1 = i - k
        if p1 >= 0:
            if len(A[p1]) >= k:
                s.add(p1)
        p2 = i + k
        if p2 < N:
            if len(A[p2]) >= k:
                s.add(p2)
        p3 = i - (k+1)
        if p3 >= 0:
            if len(A[p3]) >= k+1:
                s.add(p3)
        p4 = i + (k+1)
        if p4 < N:
            if len(A[p4]) >= k+1:
                s.add(p4)
        B.append(s)
    A = [a.union(b) for a, b in zip(A, B)]
C = [str(len(a)) for a in A]
print(" ".join(C))

Submission status: Wrong Answer

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

def calc(a):
    for _ in range(k):
        b = [0] * n
        for i in range(n):
            for j in range(n):
                if a[j] >=  abs(j - i):
                    b[i] += 1
        a = b
        print(a)
    return a

if(k > 2*log2(n) + 1):
    for i in range(n):
        print(n,end=" ")
else:
    a = calc(a)
    for i in a:
        print(i,end=" ")

Submission status: Wrong Answer

Solution code:
import math


N,K=map(int,input().split())
A=list(map(int,input().split()))
A.insert(0,0)
Atemp=[0 for i in range(len(A))]
#print(Atemp)
flag=1

for i in range(41):
    for j in range(1,len(A)):
        if A[j]==0:
            continue
        start=max(1,j-A[j])
        end=min(len(A),j+A[j]+1)
        for k in range(start,end):
            Atemp[k]+=1

    """
    for l in range(1,int(len(A)/2)):

        if Atemp[l]>abs(len(A)-l):
            flag*=1
        else:
            flag*=0

    for l in range(int(len(A)/2),len(A)):
        if Atemp[l]>l:
            flag*=1
        else:
            flag*=0

    """

    A=Atemp.copy()
    Atemp = [0 for p in range(len(A))]
    """
    if flag==1:
        for o in range(1,len(A)):
            A[o]+=(K-i+1)*len(A)
            print(o)
        break
    flag=1
    """

for m in range(1,len(A)):
    print(A[m],end=" ")

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 _ in range(k):
    new_a = np.zeros(n, dtype=int)

    for i, x in enumerate(a):
        new_a[i-x if i-x >= 0 else 0:i+x + 1] += 1
    
    a = new_a

print(*a)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
C = [[0,0] for _ in range(N)]
E = [0]*N
for i in range(N):
  C[i] = [max(0,i-A[i]),min(N-1,i+A[i])]
  E[i] = [i+1,i]
  
D = [True] * N
for _ in range(1,K+1):
  B = A.copy()
  for i in range(N):
    if D[i]:
      c = C[i]
      e = E[i]
      for j in range(c[0],e[0]):
        A[j] += 1
      E[i][0] = c[0]
        
      for j in range(e[1]+1,c[1]+1):
        A[j] += 1
      E[i][1] = c[1]
      
  for i in range(N):
    a = A[i]
    b = B[i]
    if a!=b:
      x = a-b
      c = C[i]
      C[i] = [max(0,c[0]-x), min(N-1,c[1]+x)]
      D[i] = True
    else:
      D[i] = False
  if _==1:
    for i in range(N):
      A[i] -= B[i]
      C[i] = [max(0,i-A[i]),min(N-1,i+A[i])]
  if _==K:
    print(' '.join(list(map(str, A))))
    break

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
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:
        a=[1]*n
        print(*a)
        exit()
    if min(a)==n:
        print(*a)
        exit()

    for i in range(k):
        x=zeros.copy()
        for j in range(n):
            if a[j]==0:
                l=j
                r=min(j+1,n)
                #print(l,r)
                x[l]+=1
                if r!=n:
                #print(r)
                    x[r]+=-1
                #print(x)
            else:
                l=max(0,j-a[j])
                r=min(j+a[j]+1,n)
                #print(l,r)
                x[l]+=1
                if r!=n:
                    #print(r)
                    x[r]+=-1
                #print(x)
        ruiseki=[0 for i in range(n)]
        ruiseki[0]=x[0]
        a[0]=ruiseki[0]
        mina=a[0]
        for i in range(1,n):
            ruiseki[i]=ruiseki[i-1]+x[i]
            a[i]=ruiseki[i]
            if a[i]<mina:
                mina=a[i]
 
        #print(*ruiseki)
    print(*a)
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
from math import log, ceil

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

Submission status: Wrong Answer

Solution code:
import math


N,K=map(int,input().split())
A=list(map(int,input().split()))
A.insert(0,0)
Atemp=[0 for i in range(len(A))]
#print(Atemp)
flag=1

for i in range(41):
    for j in range(1,len(A)):
        if A[j]==0:
            continue
        start=max(1,j-A[j])
        end=min(len(A),j+A[j]+1)
        for k in range(start,end):
            Atemp[k]+=1

    """
    for l in range(1,int(len(A)/2)):

        if Atemp[l]>abs(len(A)-l):
            flag*=1
        else:
            flag*=0

    for l in range(int(len(A)/2),len(A)):
        if Atemp[l]>l:
            flag*=1
        else:
            flag*=0

    """
    flag=1
    for l in range(1,len(A)):
        if Atemp[l]>=len(A)-1:
            flag*=1
        else:
            flag*=0
    if flag==1:
        A=Atemp.copy()
        break
    A=Atemp.copy()
    Atemp = [0 for p in range(len(A))]
    """
    if flag==1:
        for o in range(1,len(A)):
            A[o]+=(K-i+1)*len(A)
            print(o)
        break
    flag=1
    """

for m in range(1,len(A)):
    print(A[m],end=" ")

Submission status: Wrong Answer

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

t = [0 for _ in range(n + 1)]

def lightup(x, light):
    global t
    t[x] += 1

    for d in range(1, light + 1):
        dplus = x + d
        dminus = x - d
        print("x={}, d={}".format(x, d))
        if (dplus < n+1):
            t[dplus] += 1

        if (dminus > 0):
            t[dminus] += 1

for _ in range(k):
    for i in range(1, n + 1):
        lightup(i, a[i])

    print(a, t)
    a = list(t)
    t = [0 for _ in range(n + 1)]

a.pop(0)
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())))
# O(log N)以下で各座標が幾つの電球の範囲に含まれるかを判定したい。

for _ in range(int(np.log(n))):
    b = np.zeros(n,dtype='int64')
    for i,c in enumerate(a):
        l = max(0,i-c)
        r = min(n-1,i+c)
        tmp = (b[l:r+1]+1)
        if r < n-1:
            b = np.hstack((np.hstack((b[:l],tmp)),b[r+1:]))
        else:
            b = np.hstack((b[:l],tmp))
    a = b

print(*a)

Submission status: Wrong Answer

Solution code:
import itertools
N,K = map(int,input().split())
A = list(map(int,input().split()))
if K >= 20:
    print(*[N]*N)
    exit()
for i in range(K):
    newA = [0]*N
    for j in range(N):
        newA[max(0,j-A[j])] += 1
        if j+A[j]+1 < N:
            newA[min(N-1,j+A[j]+1)] -= 1
    A = list(itertools.accumulate(newA))
    if A == [N]*N:
        break

Submission status: Wrong Answer

Solution code:
class Range_BIT:
    def __init__(self, n):
        self.n = n
        self.bit0 = [0]*(n+1)
        self.bit1 = [0]*(n+1)
    
    def _Add(self, k, x, is_bit0=True):
        if is_bit0 == True:
            data = self.bit0
        else:
            data = self.bit1
        while k <= self.n:
            data[k] += x
            k += k & -k
    
    def _Get(self, data, k):
        s = 0
        while k:
            s += data[k]
            k -= k&-k
        return s
    
    """ 配列の獲得 """
    def Array(self):
        array = [0]*(n+1)
        for i in range(self.n):
            array[i] = self.Get(i+1,i+2)
        return array[:-1]
    
    """ 区間[l:r)に対してxを加算 """
    def Add(self, l, r, x):
        self._Add(l, -x*(l-1), is_bit0=True)
        self._Add(r, x*(r-1), is_bit0=True)
        self._Add(l, x, is_bit0=False)
        self._Add(r, -x, is_bit0=False)
    
    """ 区間[l:r)の総和 """
    def Get(self, l, r):
        Pi = self._Get(self.bit1, r-1)*(r-1) - self._Get(self.bit1, l-1)*(l-1)
        Qi = self._Get(self.bit0, r-1) - self._Get(self.bit0, l-1)
        return Pi+Qi

n,k = map(int,input().split())
A = list(map(int,input().split()))
for j in range(k):
    if j==0:
        rbit = Range_BIT(n)
        for i,a in enumerate(A):
            rbit.Add(max(1,i+1-a), min(i+2+a, n+1), 1)
    else:
        A_ = rbit.Array()
        rbit = Range_BIT(n)
        for i,a in enumerate(A_):
            rbit.Add(max(1,i+1-a), min(i+2+a, n+1), 1)
    if len(set(rbit.Array()))==1:
        break
print(*rbit.Array())

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 K in range(10):
    for i in range(n):
        num=A[i]
        for j in range(max(0,i-num),min(n,i+num+1)):
            B[j] +=1
    A=B
    B=[0 for _ in range(n)]
    if sum(A)==n**2:break
print(*A)

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()]
sum1 = sum(A)//N
if N%2 == 0:
    b = N//2
else:
    b = (N//2) +2
if N==1:
    print(1)
    exit()
if K >= 40-sum1:
    for i in range(N-1):
        print(N,end=" ")
    print(N)
    exit()
nextgen2 = [0]*N
for k in range(K):
    nextgen = nextgen2.copy()
    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
s = ' '.join([str(i) for i in A])
print(s)

Submission status: Wrong Answer

Solution code:
NK = list(map(int, input().split()))
A = list(map(int, input().split()))
ans =[0]*NK[0]
for i in range(NK[1]):
    if i == 0:
        B = set(A)
        C = sorted(list(B),reverse=True)
        for j in C:
            indexes = [m for m, e in enumerate(A) if e == j]
            for k in indexes:
                for l in range(A[k]):
                    if k + l + 1 <= NK[0] - 1 : 
                        ans[k + l + 1] += 1
                    if k - l - 1 >= 0 :
                        ans[k - l - 1] += 1
        ans =list(map(lambda x: x + 1, ans)) 
    else:
        B = set(ans)
        C = sorted(list(B),reverse=True)
        for j in C:
            indexes = [m for m, e in enumerate(ans) if e == j]
            for k in indexes:
                for l in range(ans[k]):
                    if k + l + 1 <= NK[0]- 1 : 
                        ans[k + l + 1] += 1
                    if k - l - 1  >= 0 :
                        ans[k - l - 1] += 1
print(*ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
L=list(map(int,input().split()))
L1=[-1 for _ in range(N)]
print(L1)
for k in range(K):
  for i in range(N):
    for j in range(int(L[i])+1):
      if i-j>=0:
        L1[i-j]+=1
      if i+j <N:
        L1[i+j]+=1
  if k !=K-1:
    L=L1.copy()
    L1=[-1 for _ in range(N)]
    print(L)
print(L1)

Submission status: Wrong Answer

Solution code:
import sys
n,k=map(int,input().split())
a=list(map(int,input().split()))
if n<k:
    print(*[n]*n)
else:
    for i in range(k):
        data=[0]*(n+1)
        for j in range(n):
          data[max(j-a[j-1]-1,0)]+=1
          data[min(j+a[j-1],n)]-=1
        r=[0]*n
        r[0]=data[0]  
        for i in range(1,n):
          r[i]=r[i-1]+data[i]
        if a==[n]*n:
            print(*[n]*n)
            sys.exit()
        a=r
    print(*a)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
L = [1 for _ in range(N)]
for i in range(30):
    for j in range(N):
        for k in range(j-A[j],j+A[j]+1):
            if 0 <= k < N and k != j:
                L[k] += 1
    A = L
    L = [1 for _ in range(N)]
print(*A)