Problem:


Score : 500 points

Problem Statement

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

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

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

Find the intensity of each bulb after the K operations.

Constraints

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

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

0 \leq A_i \leq N

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 \ldots A_N

Output

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

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

Sample Input 1

5 1
1 0 0 1 0

Sample Output 1

1 2 2 1 2 

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

Sample Input 2

5 2
1 0 0 1 0

Sample Output 2

3 3 4 4 3 



Sample input:
5 1
1 0 0 1 0


Sample output:
1 2 2 1 2

Submission status: Wrong Answer

Solution code:
import sys
#from itertools import accumulate
input=sys.stdin.buffer.readline

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

n,k=5,2
dp2=[1,0,0,1,0]
    
k=min(k,41)
for ki in range(1,k+1):
    ims=[0]*(n+1)
    for ni in range(n):
        if ni<dp2[ni]: ims[0]+=1
        else: ims[ni-dp2[ni]]+=1
        if n>ni+dp2[ni]:
            ims[ni+dp2[ni]+1]-=1

    dp2[0]=ims[0]
    for ni in range(1,n):
        dp2[ni]=dp2[ni-1]+ims[ni]
    
print(' '.join(map(str,dp2)))

Submission status: Wrong Answer

Solution code:
stdin = [input() for i in range(2)]
line = stdin[0].split(' ')
N = int(line[0])
K = int(line[1])
line = stdin[1].split(' ')
Ai = [0]*N
for i in range(len(line)):
    Ai[i] = int(line[i])

for i in range(K):
    Bi = [1]*N
    for i, d in enumerate(Ai):
        for j in range(1,d+1):
            if i-j >=0:
                Bi[i-j] +=1
            if i+j <N:
                Bi[i+j] +=1
    Ai = Bi

print(Ai)

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+1)]

from itertools import accumulate

for j in range(min(k,50)):
    for i in range(n):
        b[max(0,i-a[i])]+=1
        b[min(n,i+a[i]+1)]+=-1
        print(max(0,i-a[i]),min(n,i+a[i]+1),b)
    a = list(accumulate(b))[:n]
    b = [0 for i in range(n+1)]

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

Submission status: Wrong Answer

Solution code:
stdin = [input() for i in range(2)]
line = stdin[0].split(' ')
N = int(line[0])
K = int(line[1])
line = stdin[1].split(' ')
Ai = [0]*N
Bi = [0]*N
Ci = [1]*N
for i in range(len(line)):
    Ai[i] = int(line[i])

for i in range(K):
    Bi = Ci.copy()
    for i, d in enumerate(Ai):
        for j in range(1,d+1):
            if i-j >=0:
                Bi[i-j] +=1
            if i+j <N:
                Bi[i+j] +=1
    Ai = Bi.copy()

print(Ai)

Submission status: Wrong Answer

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

    for _ in range(k):
        imos = [0]*(n+1)
        finish = True
        for i, brightness in enumerate(a):
            if finish and brightness != n:
                finish = False
            begin = max(i - brightness, 0)
            end = i + brightness
            imos[begin] += 1
            if end < n:
                imos[end+1] -= 1
        if finish:
            break
        for i in range(n-1):
            imos[i+1] += imos[i]
        a = imos[:-1]
    print(*imos[:-1], sep=" ")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#東京海上日動　プログラミングコンテスト2020 c
n,k  = map(int, input().split())
ln  = list(map(int, input().split()))
import numpy as np
ln = np.array(ln)
def lamps(ln):
    line = [0 for i in range(n)]
    line = np.array(line)
    for i in range(n):
        small = i - ln[i]
        large = i + ln[i]
        if small < 0:
            small = 0
        if large > n -1:
            large = n-1
        line[small : i] += 1
        line[i + 1 : large +1] += 1
    line +=1
        
    return line
for n1 in range(k):
    ln = lamps(ln)
print(list(ln))

Submission status: Wrong Answer

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

    for _ in range(k):
        imos = [0]*(n+1)
        finish = True
        for i, brightness in enumerate(a):
            if brightness != n:
                finish = False
            begin = max(i - brightness, 0)
            end = min(i + brightness, n-1)
            imos[begin] += 1
            if end+1 < n:
                imos[end+1] -= 1
        if finish:
            break
        for i in range(n-1):
            imos[i+1] += imos[i]
        a = imos
    print(*imos[:-1], sep=" ")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

else:
    for i in range(K):
        tmp = [0] * (N + 1)
        for j in range(N):
            
            end_l = max(j - A[j], 0)
            end_r = min(j + A[j] + 1, N)
            tmp[end_l] += 1
            tmp[end_r] -= 1

        for j in range(1, N):
            tmp[j] += tmp[j - 1]
            A[j] = tmp[j]
        A[0] = tmp[0]

print(*A[:N])

Submission status: Wrong Answer

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

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

else:
    for i in range(K):
        tmp = [0] * (N + 1)
        for j in range(N):
            
            end_l = max(j - A[j], 0)
            end_r = min(j + A[j] + 1, N)
            print(end_l, end_r)
            
            if A[i] == 0:
                tmp[end_l] += 1
                tmp[end_r] -= 1
            else:
                tmp[end_l] += 1
                tmp[end_r] -= 1

        for j in range(1, N):
            tmp[j] += tmp[j - 1]
            A[j] = tmp[j]
        A[0] = tmp[0]

print(*A[:N])

Submission status: Wrong Answer

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

    for _ in range(k):
        imos = [0]*(n+1)
        finish = True
        for i, brightness in enumerate(a):
            if brightness != n:
                finish = False
            begin = max(i - brightness, 0)
            end = min(i + brightness, n-1)
            imos[begin] += 1
            if end+1 < n:
                imos[end+1] -= 1
        if finish:
            break
        for i in range(n-1):
            imos[i+1] += imos[i]
        a = imos.copy()
    print(*imos[:-1], sep=" ")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from itertools import accumulate

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

current_arr = A
imos = [0] * N
ruiseki = [0] * (N+1)
for k in range(K):
    for i, ai in enumerate(current_arr):
        imos[max([0, i-ai])] += 1
        if i+ai+1 < N:
            imos[i+ai+1] -= 1
    for j, im in enumerate(imos):
        ruiseki[j+1] = ruiseki[j] + im
#print(imos)
#print(ruiseki)
#print(*accumulate(imos))
print(*ruiseki[1:])

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=a
i=0
while i<k:
  a=b
  b=[0 for l in range(n)]
  if min(b)>=n:
    for j in range(n):
      b[j]+=n-i
    break
  else:
    for j in range(n):
      for l in range(max(0,j-a[j]),min(j+a[j]+1,n)):
        b[l]+=1
    i+=1
      #print(b,l)
print(b)

Submission status: Wrong Answer

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

    for _ in range(k):
        imos = [0]*n
        finish = True
        for i, brightness in enumerate(a):
            if brightness != n:
                finish = False
            begin = max(i - brightness, 0)
            end = i + brightness
            imos[begin] += 1
            if end+1 < n:
                imos[end+1] -= 1
        if finish:
            break
        for i in range(n-1):
            imos[i+1] += imos[i]
        a = imos.copy()
    print(*imos, sep=" ")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=a
for i in range(k):
  a=b
  b=[0 for l in range(n)]
  for j in range(n):
    for l in range(max(0,j-a[j]),min(j+a[j]+1,n)):
      b[l]+=1
      #print(b,l)
print(b)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
import numpy as np
A = np.array(input().split(), dtype=int)
I = np.arange(0, N)
for i in range(K):
  X = np.zeros(N + 1, int)
  np.add.at(X, np.maximum(0, I - A), 1)
  np.add.at(X, np.minimum(N, I + A + 1), -1)
  A = X.cumsum()[:-1]
  if np.all(A == N):
    break
print(A)

Submission status: Wrong Answer

Solution code:
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

def solve(n,k,a):
	for j in range(int(min(40,k))):
		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]
		a = b[:]

	for i in range(len(b)):
		print(b[i],end=" ")

def main():
	n,k = readInts()
	a = readInts()
	solve(n,k,a)

if __name__=='__main__':
	main()

Submission status: Wrong Answer

Solution code:
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

def solve(n,k,a):
	for j in range(int(min(20,k))):
		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]
		a = b[:]

	for i in range(len(b)):
		print(b[i],end=" ")

def main():
	n,k = readInts()
	a = readInts()
	solve(n,k,a)

if __name__=='__main__':
	main()

Submission status: Wrong Answer

Solution code:
import numpy as np

NK = list(map(int,input().split()))
A = list(map(int,input().split()))
for k in range(20):
    d = [0]*NK[0]
    for i, v in enumerate(A):
        for j in range(i-v, i+v+1):
            if j>=0 and j<len(A):
                d[j]+=1
    
    for i in range(len(A)):
        A[i] = d[i]

print(A)

Submission status: Wrong Answer

Solution code:
import numpy as np

NK = list(map(int,input().split()))
A = list(map(int,input().split()))
for k in range(41):
    d = [0]*NK[0]
    for i, v in enumerate(A):
        for j in range(i-v, i+v+1):
            if j>=0 and j<len(A):
                d[j]+=1
    
    for i in range(len(A)):
        A[i] = d[i]

print(A)

Submission status: Wrong Answer

Solution code:
N, K= input().strip().split()
N, K = [int(N), int(K)]
A = list(map(int, input().strip().split()))
B = [0]*N
for w in range(min(41,K)):
    for i in range (N):
        for j in range(max(i-A[i],0),min(A[i]+i+1,N)):
            B[j]+=1
    for k in range(N):
        A[k]=B[k]
    for o in range(N):
        B[o]=0
    if A.count(N)==N:
        break
        
        
   


print(A)

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    N, K = NMI()
    A = NLI()

    for k in range(min(K, 42)):
        tmp = [0] * (N+1)
        for i, a in enumerate(A):
            tmp[max(0, i-a)] += 1
            tmp[min(N, i+a+1)] -= 1
        cum = [0] * (N+1)
        for i, t in enumerate(tmp):
            if i == 0:
                cum[0] = t
                continue
            cum[i] = cum[i-1] + t
        A = cum[:-1]
    print(A)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    N, K = NMI()
    A = NLI()

    for k in range(min(K, 500)):
        tmp = [0] * (N+1)
        for i, a in enumerate(A):
            tmp[max(0, i-a)] += 1
            tmp[min(N, i+a+1)] -= 1
        cum = [0] * (N+1)
        for i, t in enumerate(tmp):
            if i == 0:
                cum[0] = t
                continue
            cum[i] = cum[i-1] + t
        A = cum[:-1]
    print(A)
    

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
x=input()
x0=x.split()
n=int(x0[0])
k=int(x0[1])
a0=input()
a0=a0.split()
a=[int(s) for s in a0]
for f in range(100):
    a1=list(range(n+1))
    a1=[0 for s in a1]
    for x in range(n):
        y=x-a[x]
        if y<0:
            y=0
        a1[y]=a1[y]+1    
        z=x+a[x]
        if z>n-1:
            z=n-1
        a1[z+1]=a1[z+1]-1
    for x in range(n):    
        a[x]=sum(a1[:x+1])
a=[str(s) for s in a]
a=" ".join(a)
print(a)

Submission status: Wrong Answer

Solution code:
import sys 
from collections import deque
import numpy as np
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def R(x):
    r = round(x)
    if r+0.5 <= x:
        r += 1
    return int(r)

def main():
    tmp = deque(LI())
    n,k = tmp.popleft(),tmp.popleft()
    a = LI()
    for _ in range(k):
        table = np.zeros(n)
        for j in range(n):
            left = R(max(0,j-a[j]-0.5))
            right = int(min(n-1,j+a[j]+0.5))
            table[left:right+1] += 1
        a = table[:]
    for i in range(n):
        print(str(a[i])+' ',end='')
    return

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
from numba import njit


def main(N, K, A):
    @njit(cache = True) # numpyの高速化．雲泥の差になった．知らなかった．
    def rep(N, A):
        B = np.zeros(N + 1, dtype=np.int64) # np.int64としないとnjitがエラー
        for x in range(N):
            minimum = max(0, x - A[x])
            maximum = min(N, x + A[x] + 1)
            # B[minimum:maximum] += 1   # これだと実質for文回してるような感じだから遅い？
            B[minimum] += 1
            B[maximum] -= 1
        # return B  # これだと実質for文回してるような感じだから遅い？
        return np.cumsum(B)[:-1]

    A = np.array(A, dtype=np.int64)
    for k in range(K):
        print(k)
        B = rep(N, A)
        if np.array_equal(A, B):
            break
        else:
            A = B
    return A



if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    print(' '.join([str(i) for i in main(N, K, A)]))

Submission status: Wrong Answer

Solution code:
import numpy as np
# from numba import njit
# from numba import jit

# @jit(cache = True)
def main(N, K, A):
    A = np.array(A, dtype = int)
    for k in range(K):
        # print(k)
        B = np.zeros(N + 1, dtype = int)
        for x in range(N):
            minimum = max(0, x - A[x])
            maximum = min(N, x + A[x] + 1)
            B[minimum:maximum] += 1
            # B[minimum] += 1
            # B[maximum] -= 1
            # A = np.cumsum(B)[:-1]
        if np.all(A == B):
            # print(k)
            break
        else:
            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=map(int,input().split())
a=list(map(int,input().split()))

if(k>=math.log2(n)):
    print(*[n for _ in range(len(a))])
else:
    for h in range(k):
        b=[0 for _ in range(len(a))]
        for i in range(len(a)):
            for j in range(max(0,i-a[i]),min(len(a)-1,i+a[i])+1):
                b[j]+=1
#        print(*b)
        a=b
    print(*a)

Submission status: Wrong Answer

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

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

dp = [[0] * 2 for i in range(n)]

ans = l[:]

if k > 10**3:
    k = 1000
    
for i in range(k):
    for j in range(n):
        dp[j][0] = (j+1 - ans[j] - 0.5)
        dp[j][1] = (j+1 + ans[j] + 0.5)

    ans = [0] * n

    for x in range(n):
        for y in range(n):
            if dp[y][0] <= x+1 <= dp[y][1]:
                ans[x] += 1

else:
    print(*ans)

Submission status: Wrong Answer

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

for i in range(K):
  newLightPow = [0]*(N+1)
  #print(lightPow)
  for pos in range(1, N+1):
    low = pos - lightPow[pos-1]
    high = pos + lightPow[pos-1]
    low = min(max(1, low), N)
    high = min(max(1, high), N)
    newLightPow[low-1] += 1
    newLightPow[high] -= 1
    #print("pos:"+str(pos))
    #print("low"+str(low)+" high"+str(high))
    #print(newLightPow)
    check = True
    #print(newLightPow)
    for i in range(0, N):
      if (i > 0):
      	newLightPow[i] += newLightPow[i-1]
      if (newLightPow[i] < N):
        check = False
    lightPow = newLightPow
    if (check):
      break

print(*lightPow[:-1])

Submission status: Wrong Answer

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



for i in range(K):
  newLightPow = [0]*(N+1)
  #print(lightPow)
  for pos in range(1, N+1):
    low = pos - lightPow[pos-1]
    high = pos + lightPow[pos-1]
    low = min(max(1, low), N)
    high = min(max(1, high), N)
    newLightPow[low-1] += 1
    newLightPow[high] -= 1
    #print("pos:"+str(pos))
    #print("low"+str(low)+" high"+str(high))
    #print(newLightPow)
    check = True
    #print(newLightPow)
    for i in range(1, N):
      newLightPow[i] += newLightPow[i-1]
      if (newLightPow[i] < (N-1)):
        check = False
        lightPow = newLightPow
        if (check):
          break

print(*lightPow[:-1])

Submission status: Wrong Answer

Solution code:
# 累積和
import numpy as np
from numba import njit

@njit(cache=True)
def loop(n, k, A):
    for _ in [0] * k:
        B = np.zeros(n + 1, dtype=np.int64)
        for i in range(n):
            left = max(0, i - A[i])
            right = min(n, i + A[i] + 1)
            B[left] += 1
            B[right] -= 1
        A = np.cumsum(B)[:-1]
        print(A)
        if np.all(A == n):
            return A
            break

    return A


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    A = np.array(a, dtype=np.int64)
    A = loop(n, k, A)
    print(*A)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

for i in range(K):
  newLightPow = [0]*(N+1)
  #print(lightPow)
  for pos in range(1, N+1):
    count = 0
    low = math.ceil(pos-(lightPow[pos-1]+0.5))
    high = math.floor(pos+(lightPow[pos-1]+0.5))
    low = min(max(1, low), N)
    high = min(max(1, high), N)
    newLightPow[low-1] += 1
    newLightPow[high] += 1
    #print("pos:"+str(pos))
    #print("low"+str(low)+" high"+str(high))
    #print(newLightPow)
  for i in range(1, N+1):
    newLightPow[i] += newLightPow[i-1]
  lightPow = newLightPow
  check = True
  for pow in lightPow:
    if (pow < (N-1)) :
      check = False
    if not (check):
      break
  if (check):
    break
  
print(*lightPow)

Submission status: Wrong Answer

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

A_list = np.array([0]+list(map(int, input().split())))
#print(A_np)

for j in range(1):
  new_A=np.array([0]*(N+1))
  for i in range(1,N+1):
    #print(A_np)
    mi=i-A_list[i]
    ma=i+A_list[i]
    if mi<0:
      mi=0
    if ma>N:
      ma=N
    new_A[mi:ma+1]+=1
  A_list=new_A
  if sum(A_list[1:N+1])==N*N:
    break
    
for i in range(1,N+1):
  print(A_list[i],end=" ")

Submission status: Wrong Answer

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

A_list = np.array([0]+list(map(int, input().split())))
#print(A_np)

for j in range(1):
  new_A=np.array([0]*(N+1))
  for i in range(1,N+1):
    #print(A_np)
    mi=i-A_list[i]
    ma=i+A_list[i]
    if mi<0:
      mi=0
    if ma>N:
      ma=N
    #new_A[mi:ma+1]+=1
  A_list=new_A
  if sum(A_list[1:N+1])==N*N:
    break
    
for i in range(1,N+1):
  print(A_list[i],end=" ")

Submission status: Wrong Answer

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

A_list = np.array([0]+list(map(int, input().split())))
#print(A_np)

for j in range(K):
  new_A=np.array([0]*(N+1))
  for i in range(1,N+1):
    #print(A_np)
    mi=i-A_list[i]
    ma=i+A_list[i]
    if mi<0:
      mi=0
    if ma>N:
      ma=N
    #new_A[mi:ma+1]+=1
  A_list=new_A
  if sum(A_list[1:N+1])==N*N:
    break
    
for i in range(1,N+1):
  print(A_list[i],end=" ")

Submission status: Wrong Answer

Solution code:
num=10*5
for i in range(num):
  [0 for _ in range(num)]

Submission status: Wrong Answer

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

A_list = [0]+list(map(int, input().split()))
A_np=np.array(A_list)
#print(A_np)

for j in range(1):
  new_A_np=np.zeros(N+1,dtype=np.int16)
  for i in range(1,N+1):
    #tmp_np=[0]*(N+1)
    [0 for _ in range(N+1)]
    #print(A_np)
    mi=i-A_np[i]
    ma=i+A_np[i]
    if mi<0:
      mi=0
    if ma>N:
      ma=N
    #print(mi,ma)
    #tmp_np[1:5]=1
    #print(tmp_np)
  #print(new_A_np)
  A_np=new_A_np
  if sum(A_np[1:N+1])==N*N:
    break
    
for i in range(1,N+1):
  print(A_np[i],end=" ")

Submission status: Wrong Answer

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

A_list = [0]+list(map(int, input().split()))
A_np=np.array(A_list)
#print(A_np)

for j in range(1):
  new_A_np=np.zeros(N+1,dtype=np.int16)
  for i in range(1,N+1):
    tmp_np=[0]*(N+1)
    #print(A_np)
    mi=i-A_np[i]
    ma=i+A_np[i]
    if mi<0:
      mi=0
    if ma>N:
      ma=N
    #print(mi,ma)
    #tmp_np[1:5]=1
    #print(tmp_np)
  #print(new_A_np)
  A_np=new_A_np
  if sum(A_np[1:N+1])==N*N:
    break
    
for i in range(1,N+1):
  print(A_np[i],end=" ")

Submission status: Wrong Answer

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

A_list = [0]+list(map(int, input().split()))
A_np=np.array(A_list)
#print(A_np)

for j in range(1):
  new_A_np=np.zeros(N+1,dtype=np.int16)
  for i in range(1,N+1):
    a=1+1
    #print(A_np)
    mi=i-A_np[i]
    ma=i+A_np[i]
    if mi<0:
      mi=0
    if ma>N:
      ma=N
    #print(mi,ma)
    #tmp_np[1:5]=1
    #print(tmp_np)
  #print(new_A_np)
  A_np=new_A_np
  if sum(A_np[1:N+1])==N*N:
    break
    
for i in range(1,N+1):
  print(A_np[i],end=" ")

Submission status: Wrong Answer

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

A_list = [0]+list(map(int, input().split()))
A_np=np.array(A_list)
#print(A_np)

for j in range(1):
  new_A_np=np.zeros(N+1,dtype=np.int16)
  for i in range(1,N+1):
    a=1+1
    #print(A_np)
    #mi=i-A_np[i]
    #ma=i+A_np[i]
    #if mi<0:
    #  mi=0
    #if ma>N:
    #  ma=N
    #print(mi,ma)
    #tmp_np[1:5]=1
    #print(tmp_np)
  #print(new_A_np)
  A_np=new_A_np
  if sum(A_np[1:N+1])==N*N:
    break
    
for i in range(1,N+1):
  print(A_np[i],end=" ")

Submission status: Wrong Answer

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

A_list = [0]+list(map(int, input().split()))
A_np=np.array(A_list)
#print(A_np)

for j in range(1):
  new_A_np=np.zeros(N+1,dtype=np.int16)
  for i in range(1,N+1):
    tmp_np=np.zeros(N+1,dtype=np.int16)
    #print(A_np)
    #mi=i-A_np[i]
    #ma=i+A_np[i]
    #if mi<0:
    #  mi=0
    #if ma>N:
    #  ma=N
    #print(mi,ma)
    #tmp_np[1:5]=1
    #print(tmp_np)
    new_A_np=tmp_np
  #print(new_A_np)
  A_np=new_A_np
  if sum(A_np[1:N+1])==N*N:
    break
    
for i in range(1,N+1):
  print(A_np[i],end=" ")

Submission status: Wrong Answer

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

A_list = [0]+list(map(int, input().split()))
A_np=np.array(A_list)
#print(A_np)

for j in range(1):
  new_A_np=np.zeros(N+1,dtype=np.int16)
  for i in range(1,N+1):
    tmp_np=np.zeros(N+1,dtype=np.int16)
    #print(A_np)
    mi=i-A_np[i]
    ma=i+A_np[i]
    if mi<0:
      mi=0
    if ma>N:
      ma=N
    #print(mi,ma)
    #tmp_np[1:5]=1
    #print(tmp_np)
    new_A_np+=tmp_np
  #print(new_A_np)
  A_np=new_A_np
  if sum(A_np[1:N+1])==N*N:
    break
    
for i in range(1,N+1):
  print(A_np[i],end=" ")

Submission status: Wrong Answer

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

A_list = [0]+list(map(int, input().split()))
A_np=np.array(A_list)
#print(A_np)

for j in range(1):
  new_A_np=np.zeros(N+1,dtype=np.int16)
  for i in range(1,N+1):
    tmp_np=np.zeros(N+1,dtype=np.int16)
    #print(A_np)
    mi=i-A_np[i]
    ma=i+A_np[i]
    if mi<0:
      mi=0
    if ma>N:
      ma=N
    #print(mi,ma)
    tmp_np[1:5]=1
    #print(tmp_np)
    new_A_np=tmp_np
  #print(new_A_np)
  A_np=new_A_np
  if sum(A_np[1:N+1])==N*N:
    break
    
for i in range(1,N+1):
  print(A_np[i],end=" ")

Submission status: Wrong Answer

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

A_list = [0]+list(map(int, input().split()))
A_np=np.array(A_list)
#print(A_np)

for j in range(1):
  new_A_np=np.zeros(N+1,dtype=np.int16)
  for i in range(1,N+1):
    tmp_np=np.zeros(N+1,dtype=np.int16)
    #print(A_np)
    mi=i-A_np[i]
    ma=i+A_np[i]
    if mi<0:
      mi=0
    if ma>N:
      ma=N
    #print(mi,ma)
    tmp_np[1:5]=1
    #print(tmp_np)
    new_A_np+=tmp_np
  #print(new_A_np)
  A_np=new_A_np
  if sum(A_np[1:N+1])==N*N:
    break
    
for i in range(1,N+1):
  print(A_np[i],end=" ")