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()))
target = [int(n) for _ in range(n)]
for _ in range(k):
    on = [0 for i in range(n+1)]
    for i in range(n):
        left = max((i+1) - a[i], 0)
        right = min((i+1) + a[i], n)
        for j in range(left, right+1):
            on[j] += 1
    a = on[1:]
    if a == target:
        break
    print(a)

Submission status: Wrong Answer

Solution code:
#3問目
N, K = map(int, input().split())
A = list(map(int, input().split()))
lun = [0] * N
#これだとACはでるのか
if N <= K:
    result = [N] * N
    print(result)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
dp = list(map(int,input().split()))
if k > 19:
  ans = [n for _ in range(n)]
  print(*ans)
else:
  for i in range(k):
    ndp = [0 for _ in range(n)]
    for j in range(n):
      if j-dp[j] < 0:
        ndp[0] += 1
      else:
        ndp[j-dp[j]] += 1
      if j+dp[j]+1 < n:
        ndp[j+dp[j]+1] -= 1
    for j in range(1,n):
      ndp[j] += ndp[j-1]
    dp = ndp[:]
  print(*dp)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
import numpy as np
import math
if K >= 2+math.log2(N):
    A = [N]*N
else:
    A = np.array(A)
    for _ in range(K):
        B = A
        A = np.zeros(N)
        for i in range(N):
            b = B[i]
            l, r = max(0, i-b), min(N, i+b+1)
            C = [0]*int(l)+[1]*int(r-l)+[0]*int(N-r)
            A += np.array(C)
print(' '.join(map(str, list(map(int, A)))))

Submission status: Wrong Answer

Solution code:
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))  # 整数のリスト

    next_A = [0 for _ in range(N)]

    for _ in range(K):
        for i in range(N):
            for j in range(i-A[i], i+A[i]+1):
                if j >= 0 and j < N:
                    next_A[j] += 1
        A = next_A
        next_A = [0 for _ in range(N)]

    print(A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for mou in range(K):
    newA = [0]*N
    count = 0
    for i in A:
        for j in range(-i,i+1):
            if count+j >= 0 and count + j <len(A):
                newA[count+j] += 1
        count +=1
    A = newA
print(newA)

Submission status: Wrong Answer

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

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

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

    a = l[:]

    print(a)

    if min(a) == n:
        break

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

Submission status: Wrong Answer

Solution code:
def isSatisfied(l):
  length = len(l)
  
  if any([max(i, length - i - 1) > a for i, a in enumerate(l)]):
    return False
  
  return True

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

for time in range(K):
  if isSatisfied(A):
    for i in range(N):
      A[i] += K  - time

    break
  
  NEW_A = [0] * N
  for i in range(N):
    for j in range(-A[i], A[i]+1):
      if i + j in range(0, N):
        NEW_A[i+j] += 1

  A = NEW_A
  
strA = [str(a) for a in A]

print(' '.join(strA))

Submission status: Wrong Answer

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

if K >= N:
    ans = [N] * N
    print(*ans)

Submission status: Wrong Answer

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

Bs = [1]*N

for i in range (0, N):
	if As[i] > 0:
		for j in range (max(0, i-As[i]),min(i+As[i]+1, N)):
			Bs[j]+=1
		Bs[i]-=1

Cs = [0]*N

switch = 0

for i in range (0, K-1):
	while sum(Cs) < K*N and sum(Bs) < K*N:
		if switch == 0:
			for j in range (0, N):
				for l in range (max(0, j-Bs[j]),min(j+Bs[j]+1, N)):
					if Cs[l] < N:
						Cs[l]+=1
			Bs = [0]*N
			switch = 1
		else:
			for j in range (0, N):
				for l in range (max(0, j-Cs[j]),min(j+Cs[j]+1, N)):
					if Bs[l] < N:
						Bs[l]+=1
			Cs = [0]*N	
			switch = 0

if switch == 0:
	print(*Bs)
else:
	print(*Cs)

Submission status: Wrong Answer

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

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    for _ in range(k):
        tmp = [0] * n
        for i in range(n):
            for j in range((i+1) - a[i], (i+1) + a[i] + 1):
                if 1 <= j <= n:
                    tmp[j-1] += 1
        a = tmp.copy()
        if len(set(a)) == 1:
          break
    print(*a)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(k):
    for j in range(n):
        for m in range(n):
            if a[m] >= abs(j-m):
                b[j] = b[j] + 1
    a = b
    b = [0]*n

print(a)

Submission status: Wrong Answer

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

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

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


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

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

Submission status: Wrong Answer

Solution code:
# import copy
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = [1] * n
for _ in range(k):
    for i in range(n):
        light = 0
        for j in range(n):
            if i < j:
                if (j - a[j] - 0.5) < i:
                    light += 1
            else:
                if (j + a[j] + 0.5) > i:
                    light += 1
        b[i] = light
    # a = copy.deepcopy(b)
    a = b[:]
print(a)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
# A = [0]*N
if N < K*2:
    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)
    print(A)

Submission status: Wrong Answer

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


if 2**(k-2) > n and k>5:
    ans = [n]*n
    ans=[str(a) for a in ans]
    ans=" ".join(ans)
    print(ans)
    sys.exit()


for i in range(k):
    result = np.array([0]*n, dtype=object)
    for j in range(n):
        if a_n[j] == 0:
            result[j]+=1
        else:
            j_max =j+a_n[j]
            if j-a_n[j]<=0:
                j_min =0
            else:
                j_min = j-a_n[j]
            result[j_min:j_max+1]+=1
    a_n = result
    if all(i == n for i in a_n):
        break
    
ans=[str(a) for a in a_n]
ans=" ".join(ans)
print(ans)

Submission status: Wrong Answer

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

for k in range(K):
    counterlist = np.array([0]*N)
    for i in range(N):
        d = A[i]
        u = max(0,i-d)
        v = min(N-1,i+d)
        counterlist[u:v+1]+=1
    A = counterlist
    if len(set(A))==1:
        print(*A)
        break
        

else:
    print(*A)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
g = [n]*n
for i in range(n):
    print(g[i], end = ' ')

Submission status: Wrong Answer

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

def ligh(li):
  for x in range(k):
    if li==[n]*n:
      return li
    ne=[0]*n
    ar=[]
    for (i,a) in zip(range(n),li):
      for j in range(max(0,i-a),min(i+a+1,n)):
        ne[j]+=1
    li=ne
    #print(li)
  return li

Submission status: Wrong Answer

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

for _ in range(k):
    finish=True
    start=[0]*n
    end=[0]*n
    
    for i in range(n):
        if A[i]!=n:
            finish=False
        start[max(0,i-A[i])]+=1
        end[min(n-1,i+A[i])]+=1
    if finish:
        break
    
    # update ans
    cnt=0
    for i in range(n):
        cnt+=start[i]
        A[i]=cnt
        cnt-=end[i]

print(A)

Submission status: Wrong Answer

Solution code:
import math

def pulse_num(n):
    return n + 1
if __name__ == "__main__":
    N, K= list(map(int, input().split()))
    A = list(map(int, input().split()))
    for k in range(K):
        B = [1] * len(A)
        for i in range(N):
            if A[i] != 0:
                if i - A[i] - 0.5 < 0:
                    low = 0
                else:
                    low = math.ceil(i - A[i] - 0.5)
                if i + A[i] + 0.5 > N - 1:
                    high = N - 1
                else:
                    high = math.floor(i + A[i] + 0.5)
                B[low:high+1] = list(map(pulse_num, B[low:high+1]))
                B[i] -= 1
        A = B
    
    print(A)

Submission status: Wrong Answer

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

for i in range(K):
    tmpli = [0] * (len(A)+1)
    
    for ii in range(0, N):
        L = ii - A[ii]
        if L < 0:
            L=0

        R = ii + A[ii]
        if R > N-1:
            R=N-1

        val = 1
        tmpli[L] += val
        if R+1 != N:
            tmpli[R+1] += -val

    ruiseki = [0]*N
    ruiseki[0] = tmpli[0]
    for I in range(1, N):
        ruiseki[I] = ruiseki[I-1] + tmpli[I]
        A = ruiseki

print(ruiseki)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
flag = 0
light = [0]*n
if k >= n:
    s = str(n)
    print(' '.join(list(s*n)))
    exit()
for i in range(k):
    light = [0]*n
    for j in range(n):
        light[j] += 1
        for x in range(a[j]):
            try:
                if j - (x+1) < 0:continue
                light[j-(x+1)] += 1
            except IndexError:
                pass
        for x in range(a[j]):
            try:
                if j + (x+1) < 0:continue
                light[j+x+1] += 1
            except IndexError:
                pass
    if len(set(light)) == 1:
        break
    a = light
for i in range(n):
    print(light[i],end=' ')

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
i_list = input().split()
d_list = [0]*n

for x in range(k-1):
  
  for x in range(n-1):
    #y=int(i_list[x])-1
    
    add = [1]*(int((i_list[x]))*2)
    d_list[x-int(i_list[x]):x+int(i_list[x])] += add
  
  i_list += d_list
  d_list = [0]*n
  
print(i_list)

Submission status: Wrong Answer

Solution code:
import sys
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
DP = [[0 for _ in range(N)] for _ in range(K+1)]
for i in range(N):
    DP[0][i] = A[i]

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
import numpy as np
import math
if K >= 1+math.log2(N):
    A = [N]*N
else:
    A = np.array(A)
    for _ in range(K):
        B = A
        A = np.zeros(N)
        for i in range(N):
            b = B[i]
            l, r = max(0, i-b), min(N, i+b+1)
            C = [0]*int(l)+[1]*int(r-l)+[0]*int(N-r)
            A += np.array(C)
print(' '.join(map(str, list(map(int, A)))))

Submission status: Wrong Answer

Solution code:
N, K = [int(v) for v in input().strip().split(" ")]
A = [int(v) for v in input().strip().split(" ")]

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

print(A)

Submission status: Wrong Answer

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

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

for i in range(K):
    A=henkan(A,N)

print(A)

Submission status: Wrong Answer

Solution code:
import copy
N,K=map(int, input().split())
A=list(map(int, input().split()))
for a in range(0,K):
    B = [0] * N
    for x in range(0,N):
        d = A[x]
        low = int(x - d - 0.5+1)
        high = int(x + d + 0.5+1)
        if low < 0:
            low = 0
        if high > N:
            high = N
        if d == 0:
            B[x] += 1
        else:
            for i in range(low,high):
                B[i] += 1

    A = copy.deepcopy(B)
print(B)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 累乗 #####
# pow(x, y, z) -> x**y % z

##### 割り算の切り上げ #####
# tmp = -(-4 // 3)

##### dict の for文 #####
# for k, v in d.items():
#     print(k, v)

##### 進数の変換 #####
# bin_str = bin(i)[2:]
# oct_str = oct(i)[2:]
# hex_str = hex(i)[2:]

##### とても大きな数 と 小数の計算誤差 #####
# 「Decimal」は計算誤差を 0にできる。必要に応じて粒度を設定せよ。
# getcontext().prec = 100
#
# tmp = Decimal(i)
# A,B = map(Decimal, input().split())
# ans = A * B

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N,K = inputMap()
	A = inputList()

	if N > 100000:
		T = [K for i in range(N)]
		print(*T)
		sys.exit()

	for j in range(K):
		T = [0 for i in range(N)]
		for i,val in enumerate(A):
			#print(T)
			tmp_min = max(0,i-val)
			T[tmp_min] += 1

			if i+val+1 > N-1:
				continue
			tmp_max = min(N-1,i+val+1)
			T[tmp_max] -= 1

		for i,val in enumerate(T):
			if i == 0:
				continue
			T[i] += T[i-1]
		A = T

	print(*A)



def segfunc(x, y):
    return 0

ide_ele = float('inf')

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# 2分検索のリバース
def bisect_left_reverse(a, x):
    if a[0] <= x:
        return 0
    if x < a[-1]:
        return len(a)
    # 二分探索
    ok = len(a) - 1
    ng = 0
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if a[mid] <= x:
            ok = mid
        else:
            ng = mid
    return ok

def bisect_right_reverse(a, x):
    if a[0] < x:
        return 0
    if x <= a[-1]:
        return len(a)
    # 二分探索
    ok = len(a) - 1
    ng = 0
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if a[mid] < x:
            ok = mid
        else:
            ng = mid
    return ok

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# 2分検索
# 存在しない場合: None 存在する場合: その値
def binary_search(list, item):
    low = 0
    high = len(list) - 1

    while low <= high:
        mid = (low + high) //2
        guess = list[mid]
        if guess == item:
            return mid
        if guess > item:
            high = mid -1
        else:
            low = mid + 1
    return None

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# N 個のボールを K グループに分ける場合のパターン数
def sunuke(N, K, mod=10**9+7):
	if N < K or K-1 < 0:
		return 0
	else:
		return combination(N-1, K-1, mod)

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# nCr mod m
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

# mを法とするaの乗法的逆元
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# nHr mod m
# 問題によって、combination()を切り替えること
def H(n, r, mod=10**9+7):
	# comb = Combination(n+r-1, mod)
	# return comb(n+r-1, r)
    return combination(n+r-1, r, mod)


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# dfs のサンプル
def dfs(graph,parent,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Bs = [1]*N

for i in range (0, N):
	if As[i] > 0:
		for j in range (max(0, i-As[i]),min(i+As[i]+1, N)):
			Bs[j]+=1
		Bs[i]-=1

Cs = [0]*N

switch = 0

for i in range (0, K-1):
	if switch == 0:
		while sum(Cs) < K*N:
			for j in range (0, N):
				for l in range (max(0, j-Bs[j]),min(j+Bs[j]+1, N)):
					if Cs[l] < N:
						Cs[l]+=1
		Bs = [0]*N
		switch = 1
	else:
		while sum(Bs) < K*N:
			for j in range (0, N):
				for l in range (max(0, j-Cs[j]),min(j+Cs[j]+1, N)):
					if Bs[l] < N:
						Bs[l]+=1
		Cs = [0]*N	
		switch = 0

if switch == 0:
	print(Bs)
else:
	print(Cs)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import copy as cp

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

threshold = 15

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

Submission status: Wrong Answer

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

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

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

print(data)

Submission status: Wrong Answer

Solution code:
import math
import copy


def init():
    game_info = input().split(" ")
    light_list = {}

    light_count = int(game_info[0])
    act_count = int(game_info[1])

    for index, value in enumerate(input().split(" ")):
        light_list[index + 1] = int(value)

    return act_count, light_list, light_count


def check_min(key, value):
    if math.ceil(key - value - 0.5) < 1:
        return 1

    else:
        return math.ceil(key - value - 0.5)


def check_max(key, value, light_count):
    if math.floor(key + value + 0.5) > light_count:
        return light_count

    else:
        return math.floor(key + value + 0.5)


def main():
    act_count, light_list, light_count = init()

    for i in range(act_count):
        result = {}
        for key, value in light_list.items():
            min = check_min(key, value)
            max = check_max(key, value, light_count)

            for x in range(min, max + 1):
                if x in result:
                    result[x] = result[x] + 1
                else:
                    result[x] = 1
        print(result)
        light_list = copy.deepcopy(result)

    print(' '.join([str(i) for i in result.values()]))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

for k in range(K):
	A_new = [0]*N
	for i in range(N):
		A_new[i] += 1
		for d in range(1, A[i]+1):
			if((i+d)<N):
				A_new[i+d] += 1
			if((i-d)>=0):
				A_new[i-d] += 1
	A = deepcopy(A_new)

print(A_new)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
for kk in range(k):
  b = []
  for i,j in enumerate(a):
    il = i
    ir = i
    sl = 1
    sr = 1
    bi = 1
    while il != 0:
      il -= 1
      if a[il] >= sl:
        bi += 1
      sl += 1
    while ir != n-1:
      ir += 1
      if a[ir] >= sr:
        bi += 1
      sr += 1
    b.append(bi)
  a = b
print(b)

Submission status: Wrong Answer

Solution code:
import copy as cp

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

threshold = 12

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