Problem:


Score : 500 points

Problem Statement

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

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

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

Find the intensity of each bulb after the K operations.

Constraints

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

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

0 \leq A_i \leq N

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 \ldots A_N

Output

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

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

Sample Input 1

5 1
1 0 0 1 0

Sample Output 1

1 2 2 1 2 

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

Sample Input 2

5 2
1 0 0 1 0

Sample Output 2

3 3 4 4 3 



Sample input:
5 1
1 0 0 1 0


Sample output:
1 2 2 1 2

Submission status: Wrong Answer

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

for i in range(k + 1):
    a.append([0] * n)
flag = 0

for i in range(k):
    if i == 0:
        for j in range(n):
            for l in range(-a[i][j], a[i][j] + 1):
                if 0 <= j + l < n:
                    a[i + 1][j + l] += 1
    else:
        cnt = 0
        for j in range(n):
            a[i + 1][j] += a[i][j]
            if a[i][j] == n:
                cnt += 1
        if cnt == n:
            flag = 1
            print(*a[i])
            break
        for j in range(n):
            if a[i][j] - a[i - 1][j] != 0:
                for l in range(1, a[i][j] - a[i - 1][j] + 1):
                    if 0 <= j - a[i - 1][j] - l:
                        a[i + 1][j - a[i - 1][j] - l] += 1
                    if j + a[i - 1][j] + l < n:
                        a[i + 1][j + a[i - 1][j] + l] += 1


if flag == 0:
    print(*a[k])

Submission status: Wrong Answer

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

for _ in range(k):
    if np.all(n):
        break
    temp = np.zeros(n)
    for i in range(n):
        left, right = max(0,i-a[i]), min(i+a[i],n-1)
        temp[left]+=1
        if right+1<n:
            temp[right+1]-=1
    for i in range(n-1):
        temp[i+1]+=temp[i]
    a=temp.copy()
        
for val in a:
    print(val, end=" ")

Submission status: Wrong Answer

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

def lamp(A):
  B = [0] * N
  for i in range(N):
    l = max(0, i - A[i])
    r = min(N - 1, i + A[i])
    #print(l, r)
    B[l] += 1
    if r + 1 < N:
      B[r + 1] -= 1
  
  A[0] = B[0]
  for i in range(1, N):
    A[i] = A[i - 1] + B[i]
  return A

x = int(math.log(N, 2)) + 10
r = min(x, K)
for i in range(r):
  A = lamp(A)
  
for i in range(N):
  print(A[i], end = " ")
print("")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

while c<=k:
    b=[0 for i in range(n)]
    for i in range(n):
        l=max(0,i-a[i])
        r=min(n-1,i+a[i])
        b[l]+=1
        if r+1<n:
            b[r+1]-=1
    for i in range(1,n):
        b[i]+=b[i-1]
    if min(b)==n:
        break
    c+=1
    a=b
print(a)

Submission status: Wrong Answer

Solution code:
def conv(A,N):
    #A(座標iの電灯の強さリスト)からB(座標iを照らしている電灯数)への変換
    B=[0 for n in range(N)]
    for n in range(1,N+1):
        il_min=max(int(n-A[n-1]-0.5)+1,1)
        il_max=min(int(n+A[n-1]+0.5),N)
        for i in range(il_min,il_max+1):
            B[i-1]+=1
    return B

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

    if K>45:
        A=[N for n in range(N)]
    else:
        for k in range(K):
            B=conv(A,N)
            if A==B:
                break
            else:
                A=B
            print(B)
    return " ".join(list(map(str,A)))

if __name__=="__main__":
    print(main())

Submission status: Wrong Answer

Solution code:
import math

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    
    if K > int(math.log(N))+2:
        K = int(math.log(N))+2
    
    for k in range(K):
        B = [0 for i in range(N)]
        for i in range(N):
            low = max(0,i-A[i])
            high = min(N-1,i+A[i])
            B[low] += 1
            if high+1 < N:
                B[high+1] -= 1
        for i in range(1,N):
            B[i] += B[i-1]
        A = B
    
    print(*A)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    
    if K > int(math.log(N))+1:
        K = int(math.log(N))+1
    
    for k in range(K):
        B = [0 for i in range(N)]
        for i in range(N):
            low = max(0,i-A[i])
            high = min(N-1,i+A[i])
            B[low] += 1
            if high+1 < N:
                B[high+1] -= 1
        for i in range(1,N):
            B[i] += B[i-1]
        A = B
    
    print(*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()))
for _ in range(min(K, 2*int(math.log(K)+1))):
    B = [0]*N
    for i in range(N):
        left = max(0, i-A[i])
        right = min(N-1, i+A[i])
        B[left] += 1
        if right+1 <= N-1:
            B[right+1] -= 1
    for i in range(N-1):
        B[i+1] += B[i]
    A = B[:]
print(*A)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
from numba import njit
import sys

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

lamps = np.array(lamps)

@njit(cache=True)
def loop():
    for i in range(k):
        result = np.array([0] * n)

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

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


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


            result += tmp
        lamps = result

    return lamps

print(loop)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations, accumulate
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

N, K = read_ints()
A = read_ints()
# N = K = 2 * 100000
# A = [0] * N

# 愚直に実装するとO(N**3)ぐらいO(N√N)以下じゃないと間に合わない
# 一回あたりの操作はO(N)(imos法)
# 操作回数はmin(K,logN)に気づくと通る

for _ in range(min(40, K)):
    imos = [0] * (N + 1)
    for i, d in enu(A):
        imos[max(i - d, 0)] += 1
        imos[min(i + d + 1, N)] -= 1
    A = list(accumulate(imos))[:-1]
print(*A)

Submission status: Wrong Answer

Solution code:
# 幅優先探索（行きがけ）
import collections
import sys
import copy


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N, K = LI()
    aArray = LI()
    result = [0]*(N)

    for i in range(K):
        aArray2 = copy.copy(aArray)
        if sum(aArray) < N**2:
            for j in range(N):
                result[j] += 1
                for k in range(aArray[j]):
                    mai = j-k-1
                    pul = j+k+1
                    if mai > 0:
                        result[mai] += 1
                        if aArray2[mai] < N:
                            aArray2[mai] += 1
                    if pul < N:
                        result[pul] += 1
                        if aArray2[pul] < N:
                            aArray2[pul] += 1
                if aArray[j] < N:
                    aArray2[j] += 1
            aArray = aArray2
        else:
            for c in result:
                c += (K-i)*N
            break
    print(*result)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

while K > 0 and not conv:
    K -= 1
    b = [0]*(N+1)
    for i in range(N):
        l, r = i - A[i], i + A[i] + 1
        if l < 0:   l = 0
        if r > N:   r = N
        b[l] += 1
        b[r] -= 1

    A[0], conv = b[0], True
    for i in range(1, N):
        A[i] = A[i-1] + b[i]
        if not conv and b[i] != 0:
            conv = False

if conv:
    print(' '.join(map(str, [N]*N)))
else:
    print(' '.join(map(str, A)))

Submission status: Wrong Answer

Solution code:
import math

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    
    if K > math.log(N):
        K = int(math.log(N))+1
    
    for k in range(K):
        B = [0 for i in range(N)]
        for i in range(N):
            low = max(0,i-A[i])
            high = min(N-1,i+A[i])
            B[low] += 1
            if high+1 < N:
                B[high+1] -= 1
        for i in range(1,N):
            B[i] += B[i-1]
        A = B
    
    print(*A)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for k in range(K):
    for i in range(N):
        if A[i] != N:
            break
    else:
        break

    B = [0] * N
    for i in range(N):
        d = A[i]
        left = max(0, i - d)
        right = min(N-1, i + d)
        B[left] += 1
        if right + 1 < N:
            B[right+1] -= 1
    for i in range(1, N):
        B[i] += B[i-1]
    A = B
print(" ".join(map(str, A)))

Submission status: Wrong Answer

Solution code:
import copy
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = [n for i in range(n)]
#最初に右側だけを考慮
right = [0 for i in range(n)]
#print(a)
aa = copy.deepcopy(a)
for cnt in range(k):
    if aa == a and cnt != 0:
        break
    r_check = {}
    r_kinds = 0
    for i,j in enumerate(aa):
        p = copy.deepcopy(r_kinds)
        if i in r_check:
            r_kinds -= r_check[i]
        num = 1 + p
    #print(num,p,r_check,i)
        if num <= n:
            right[i] = num
        else:
            right[i] = n
        if j != 0:
            if not i + j in r_check:
                r_check[i + j] = 1
            else:
                r_check[i + j] += 1
            r_kinds += 1
        #print(right,r_kinds,r_check)
    aa = right
    #print(right)
#print(right,8888)
#次に左側だけを考慮
left = [0 for i in range(n)]

b = a[::-1]
bb = copy.deepcopy(b)
#print(b)
for cnt in range(k):
    if bb == b and cnt != 0:
        break
    l_check = {}
    l_kinds = 0
    for i,j in enumerate(bb):
        p = copy.deepcopy(l_kinds)
        if i in l_check:
            l_kinds -= l_check[i]
        num = 1 + p
            #print(num,p,r_check,i)
        if num <= n:
            left[i] = num
        else:
            left[i] = n
        if j != 0:
            if not i + j in l_check:
                l_check[i + j] = 1
            else:
                l_check[i + j] += 1
            l_kinds += 1
        #print(left,l_kinds,l_check)
    bb = left
    #print(left)
left = left[::-1]
#print(left,8888)
#最後にそれを足し算
for i in range(n):
    ans[i] = right[i]+left[i]
ans = list(map(lambda x:x-1,ans))
ans = list(map(str,ans))
#print(right,left)
print(" ".join(ans))

Submission status: Wrong Answer

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

#累積和

for _ in range(42):
    B = [0]*N
    for i in range(N):
        l = max(0,i-A[i])
        r = min(N-1, i+A[i])
        B[l] += 1
        if r+1 < N: B[r+1] -= 1
    for i in range(1,N):
        B[i] += B[i-1]
    B, A = A, B

print(*A)

Submission status: Wrong Answer

Solution code:
import math

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
for _ in range(int(math.log2(K)+1)):
    B = [0]*N
    for i in range(N):
        left = max(0, i-A[i])
        right = min(N-1, i+A[i])
        B[left] += 1
        if right+1 <= N-1:
            B[right+1] -= 1
    for i in range(N-1):
        B[i+1] += B[i]
    A = B[:]
print(*A)

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

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 for i in range(N)] for j in range(K + 1)]
lamps[0] = A

if K > 20:
    b = [str(N)] * N
    print(" ".join(b))
    sys.exit()

"""
累積和〜
"""
for i in range(K):
    if lamps[i] == [N for i in range(N)]:
        ans = [str(N) for i in range(N)]
        print(" ".join(ans))
    tmps = [0 for i in range(N)]
    for j in range(N):
        w = lamps[i][j]
        tmps[max(0, j - w)] += 1
        r = min(N-1, j + w)
        if r + 1 < N:
            tmps[r + 1] -= 1
    hoge = 0
    for j in range(N):
        hoge += tmps[j]
        lamps[i + 1][j] = hoge
ans = lamps[-1]
ans = map(str, ans)
print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N,K = map(int,input().split())
A = list(map(int,input().split()))
if N == 1:
    print(1)
else:
    cnt = 1
    while 2 ** (cnt-1) < N:
        cnt += 1
    cnt += 1
    if cnt+2 <= K:
        ans = [N]*N
        print(" ".join(map(str,ans)))
    else:
        old = A
        for _ in range(K):
            li = [0]*N
            for i in range(N):
                MIN = max(0,i-old[i])
                MAX = min(N-1,i+old[i])
                li[MIN] += 1
                if MAX != N-1:
                    li[MAX+1] -= 1
            old = accumulate(li)
            old = list(old)
            if min(old) == N:
                break
        print(*old)

Submission status: Wrong Answer

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

diff_list = [0 for num in range(n)]
diff_list[0] = a_in[0]
for i in range(1, n):
    diff_list[i] = a_in[i] - a_in[i-1]

itr = k
if k > 41:
    itr = 41
for i in range(itr):
    new_list = [0 for num in range(n)]
    d_sum = 0
    for j, d in enumerate(diff_list):
        d_sum += d
        new_list[max(j-d_sum, 0)] += 1
        new_list[min(j+d_sum+1, n-1)] -= 1
    # print(new_list)
    diff_list = new_list.copy()

ans = 0
for d in diff_list:
    ans += d
    print(ans, end= ' ')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

def shine(n,j):
  inf = math.ceil(max(j - n - 0.5,1)) - 1
  sup = math.floor(min(j + n + 0.5,N))
  for k in range(inf,sup):
    tmp[k] += 1

lim = min(50,K)

while lim > 0:
  tmp = [0] * N
  for i in range(0,N):
    shine(light[i],i + 1)
  light = tmp
  lim -= 1
    
print(light)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=[0 for i in range(N)]
#print(B)
for i in range(45):
    for j in range(N):
        for k in range(1,N):
            if j+k<=N-1:
                if A[j+k]>=k:
                    B[j]+=1
                    #print(j,k)
                    #print("22")
            if j-k>=0:
                if A[j-k]>=k:
                    B[j]+=1
                    #print(j,k)
                    #print("33")
        B[j]+=1
    A=B
    B=[0 for i in range(N)]
ans=[str(a) for a in A]
ans=" ".join(ans)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N,K = map(int,input().split())
A = list(map(int,input().split()))
if N == 1:
    print(1)
else:
    cnt = 1
    while 2 ** (cnt-1) < N:
        cnt += 1
    cnt += 1
    if cnt+1 <= K:
        ans = [N]*N
        print(" ".join(map(str,ans)))
    else:
        old = A
        for _ in range(K):
            li = [0]*N
            for i in range(N):
                MIN = max(0,i-old[i])
                MAX = min(N-1,i+old[i])
                li[MIN] += 1
                if MAX != N-1:
                    li[MAX+1] -= 1
            old = accumulate(li)
            old = list(old)
        print(*old)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=[0 for i in range(N)]
#print(B)
for i in range(60):
    for j in range(N):
        for k in range(1,N):
            if j+k<=N-1:
                if A[j+k]>=k:
                    B[j]+=1
                    #print(j,k)
                    #print("22")
            if j-k>=0:
                if A[j-k]>=k:
                    B[j]+=1
                    #print(j,k)
                    #print("33")
        B[j]+=1
    A=B
    B=[0 for i in range(N)]
ans=[str(a) for a in A]
ans=" ".join(ans)
print(ans)

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

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 for i in range(N)] for j in range(K + 1)]
lamps[0] = A

if K > 15:
    b = [str(N)] * N
    print(" ".join(b))
    sys.exit()

"""
累積和〜
"""
for i in range(K):
    tmps = [0 for i in range(N)]
    for j in range(N):
        w = lamps[i][j]
        tmps[max(0, j - w)] += 1
        r = min(N-1, j + w)
        if r + 1 < N:
            tmps[r + 1] -= 1
    hoge = 0
    for j in range(N):
        hoge += tmps[j]
        lamps[i + 1][j] = hoge
ans = lamps[-1]
ans = map(str, ans)
print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np
from math import log

def main(N, K, A):
    A = np.array(A, dtype = int)
    if K > log(N):
        A = [N for _ in range(N)]
    else:
        for k in range(K):
            B = np.zeros(N, dtype = int)
            for x in range(N):
                if A[x] >= N - 1:
                    B += 1
                else:
                    minimum = max(0, x - A[x])
                    maximum = min(N, x + A[x] + 1)
                    B[minimum:maximum] += 1
                A = B
    print(' '.join([str(i) for i in A]))



if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    main(N, K, A)

Submission status: Wrong Answer

Solution code:
import math

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
for _ in range(int(math.log(K)+1)):
    B = [0]*N
    for i in range(N):
        left = max(0, i-A[i])
        right = min(N-1, i+A[i])
        B[left] += 1
        if right+1 <= N-1:
            B[right+1] -= 1
    for i in range(N-1):
        B[i+1] += B[i]
    A = B[:]
print(*A)

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
  if ans1==list(range(1,n+1)):
    ans1=[n]*n
    break
  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



print(*ans1)

Submission status: Wrong Answer

Solution code:
import numpy as np 
from numba import jit
n,k=map(int,input().split())
a=list(map(int,input().split()))
arr=np.array(a)

@jit
def imo(a):
    imos=np.zeros(n+1,dtype="int64")
#print(arr[0])
    for i in range(n):
        imos[max(0,i-arr[i])]+=1
        imos[min(n,i+arr[i]+1)]-=1
    
    immo=np.zeros(n+1)
    immo=np.cumsum(imos)
    return immo[:n]


for _ in range(min(k,41)):
    arr=imo(arr)
    
print(*arr)

Submission status: Wrong Answer

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

def solve(N: int, K: int, A: "List[int]"):

    while(sum(A)<=K*N):
        B = [0] * N
        for i in range(N):
            d = A[i]
            if d == 0:
                B[i] += 1
                continue

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

        A = B.copy()
    print(*A)
        
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

K = min(K, int(math.log(2*10**5))+1)
dp = [[0]*N for _ in range(K)]

for i in range(N):
    temp = S[i]
    m = max(0, i-temp)
    dp[0][m] += 1
    if N > i+temp+1:
        dp[0][i+temp+1] -= 1

for i in range(K-1):
    temp = 0
    for j in range(N):
        temp += dp[i][j]
        m = max(0, j-temp)
        dp[i+1][m] += 1
        if N > j+temp+1:
            dp[i+1][j+temp+1] -= 1

ans = [0]*N
ans[0] = dp[K-1][0]

for i in range(1, N):
    ans[i] = ans[i-1] + dp[K-1][i]

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=[0]*n
num=[]
if k>=41:
    ans=[n]*n
    print(*ans)
else:
    for i in range(k):
        num=[0]*n
        for j in range(n):
            if a[j]>j:
                num1=0
            else:
                num1=j-a[j]
            num[num1]+=1
            if j+a[j]+1<n:
                num[j+a[j]+1]-=1
        num5=0
        for j in range(n):
            num5+=num[j]
            ans[j]=num5
        a=ans
print(*a)

Submission status: Wrong Answer

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

import math
K = min(K, int(math.log2(N)) + 1)
for k in range(K):
  light = [0] * (N+1)
  for i in range(N):
    start = max(0,i-A[i])
    end = min(N-1, i+A[i])
    light[start] += 1
    light[end+1] -= 1
  for i in range(1,N):
    light[i] += light[i-1]
    
  A = light

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

Submission status: Wrong Answer

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

for i in range(k):

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

Submission status: Wrong Answer

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

import math
K = min(K, int(math.log(N))+2)
for k in range(K):
  light = [0] * (N+1)
  for i in range(N):
    start = max(0,i-A[i])
    end = min(N-1, i+A[i])
    light[start] += 1
    light[end+1] -= 1
  for i in range(1,N):
    light[i] += light[i-1]
    
  A = light

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

Submission status: Wrong Answer

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

        for k in range(N):
            A[k] = foo[k]
        #print(A)
else:
    for k in range(N):
        A[k] = N


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for k in range(50):
  copy=[0]*N
  for i in range(N):
    kido=light[i]
    smin=max(0,i-kido)
    smax=min(N-1,i+kido)
    for j in range(smin, smax+1):
      copy[j]+=1
  light=copy
print(*light)

Submission status: Wrong Answer

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

B = [1 for a in A]

for k in range(K, 500):
    for i in range(N):
        for j in range(1, A[i]+1):
            if i - j >= 0:
                B[i-j] += 1
            if i + j < N:
                B[i+j] += 1
    A = [b for b in B]
    B = [1 for a in A]

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

Submission status: Wrong Answer

Solution code:
import copy

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

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

Submission status: Wrong Answer

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

import math
K = min(K, int(math.log(N)) + 1)
for k in range(K):
  light = [0] * (N+1)
  for i in range(N):
    start = max(0,i-A[i])
    end = min(N-1, i+A[i])
    light[start] += 1
    light[end+1] -= 1
  for i in range(1,N):
    light[i] += light[i-1]
    
  A = light

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
ls=list(map(int,input().split()))
for _ in range(K):
  if ls==[N]*N:
    break
  else:   
    R=[0]*(N)
    for i in range(N):
      R[max([0,i-ls[i]])]+=1
      if i+ls[i]+1<N:
        R[i+ls[i]+1]-=1  
    ls[0]=R[0]
    for i in range(N-1):
      ls[i+1]=ls[i]+R[i+1]   
for i in range(N):
  print(ls[i],end="")

Submission status: Wrong Answer

Solution code:
import math

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
for _ in range(int(math.log(K)+1)):
    tmp = [0]*N
    for i in range(N):
        left = max(0, i-A[i])
        right = min(N-1, i+A[i])
        for j in range(left, right+1):
            tmp[j] += 1
    A = tmp[:]
    if all([N == x for x in A]):
        break
print(*A)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
A = list(map(int, input().split()))
A2 = [0] * n
A3 = [n] * n
 
if k > n:
  print(*A3)
else:
  for l in range(41):
    for j in range(n):
      if A[j] == n:
         A2[j] =n
      else:
        for i in range(n):
          if A[i] >= abs(i-j):
             A2[j] += 1
    A = A2
    A2 = [0] * n
    if A == [n]*n:
      break
 
print(*A)