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:
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,0)
        il_max=min(int(n+A[n-1]+0.5),N)
        for i in range(il_min-1,il_max):
            B[i]+=1
    return B

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

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

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

Submission status: Wrong Answer

Solution code:
i=(input().split())
j=(input().split())

N=i[0]
K=i[1]


e=[]
f=[]

for z in range(int(K)):
    f=[]
    for x in range(int(N)):
        d=[]
        for y in range(int(N)):
            if x == y:
                d.append(1)
            else: 
                if int(j[y]) != 0:
                    if abs(x-y) <= int(j[y]):
                        d.append(1)
                    elif abs(x-y) > int(j[y]):
                        d.append(0)
                elif int(j[y]) == 0:
                    d.append(0)
        f.append(sum(d))
    j=f
    
    
print(f)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
a=list(map(int,input().split()))
if K>=N-1:
    ans=[N]*N
    print(' '.join(map(str,ans)))
else:
    pass

Submission status: Wrong Answer

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


class RAQ():
    
    def __init__(self, size):
        """初期化"""
        self.size = size
        n = 2 ** ((size-1).bit_length())
        treesize = n * 2
        st = [0] * treesize
        self.st = st
        self.offset = len(st) // 2

    @classmethod
    def from_array(cls, a):
        st = cls(len(a))
        for i, x in enumerate(a):
            st.add(i, i+1, x)
        return st

    def _add_topdown(self, a, b, value, k=1, l=0, r=-1):
        """区間[a, b) に対する加算
        k: 着目しているノード (1-indexed)
        l: 探索区間 st[l, r) の左端 (0-indexed)
        r: 探索区間 st[l, r) の右端 (0-indexed)
        """
        if r == -1:
            r = self.offset
        if r <= a or b <= l:
            return
        if l == r - 1:
            self.st[k] += value
            return
        if a <= l and r <= b:
            self.st[k] += value
            return
        mid = (l + r) // 2
        self._add(a, b, value, k * 2, l, mid)
        self._add(a, b, value, k * 2 + 1, mid, r)

    def _add_bottomup(self, a, b, value):
        """区間[a, b) に対する加算
        """
        a += self.offset
        b += self.offset - 1
        while a < b:
            if a & 1:
                self.st[a] += value
                a += 1
            a >>= 1
            if not b & 1:
                self.st[b] += value
                b -= 1
            b >>= 1
        if a == b:
            self.st[a] += value

    def add(self, a, b, value):
        """区間[a, b) に対する加算"""
        if a > b:
            raise ValueError("a must be less than equal b.")
        return self._add_bottomup(a, b, value)

    def get(self, key):
        """値の取得"""
        offset = len(self.st) // 2
        k = offset + key
        v = self.st[k]
        k >>= 1
        while k > 0:
            v += self.st[k]
            k >>= 1
        return v


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


def solve(N, K, A):
    KL = int(math.log2(N) * 2) + 2
    if K > KL:
        print(' '.join([str(N)] * N))
        return
    raq = RAQ.from_array(A)
    a = [0 for i in range(N)]

    for k in range(min(K, KL)):
        for i in range(N):
            a[i] = raq.get(i)
            raq.add(i, i+1, -a[i])
        for i in range(N):
            l = max(0, i-a[i])
            r = min(N, i+1+a[i])
            raq.add(l, r, 1)
    print(' '.join([str(raq.get(i)) for i in range(N)]))


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Wrong Answer

Solution code:
import copy
N,K = map(int,input().split())
A = list(map(int,input().split()))
#B = copy.copy(A)
#B = [0 for _ in range(N)]
for t in range(K):
  while min(A) >= N:
    ans = [N]*N
    print(ans)
    exit()
  B = [0 for _ in range(N)]
  for i in range(N):
    MIN = max(0,i-A[i])
    MAX = min(N-1,i+A[i])
    p = MIN
    while p<=MAX:
      B[p] +=1
      p += 1
  A = B
print(B)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n, k = [int(x) for x in stdin.readline().rstrip().split()]
intense_counters = [0]
dd = [int(x) for x in stdin.readline().rstrip().split()]
intense_counters.extend(dd)

max_intense = False
additional = 0
for times in range(k):
    counter = 0
    new_intense_counters = [0] * (n+1)
    add_all = 0
    for i, intense in enumerate(intense_counters):
        if i == 0:
            continue
        intense += additional

        if intense == n:
            counter += 1
            add_all += 1
        else:
            min = i - intense
            if min < 1:
                min = 1
            max = i + intense
            if max > n:
                max = n

            if min == 1 and max == n:
                add_all += 1
            else:
                for lighted_position in range(min, max+1):
                    new_intense_counters[lighted_position] += 1
    if counter == n:
        max_intense = True
        break
    intense_counters = new_intense_counters
    additional = add_all

if max_intense:
    print(" ".join(list(map(str, [n]*n))))
else:
    print(" ".join(list(map(str, intense_counters[1:]))))

Submission status: Wrong Answer

Solution code:
N,K = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [0] * N
if K*N >= 10**5:
    ans = [min(N,K)] * N
    for i in range(N):
        print(ans[i],end=" ")
        exit()
for i in range(K):
    for j in range(N):
        b[j] = a[j]
    a = [0] * N
    for j in range(N):
        for k in range(max(0,j-b[j]),min(j+b[j],N-1)+1):
            a[k] += 1
for i in range(N):
    print(a[i],end=" ")

Submission status: Wrong Answer

Solution code:
import numpy as np

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

Ai = np.arange(1, N+1, 1)
Ap = np.copy(A)
for i in range(K):
  for j in range(N):
    A[j] = np.sum((Ap - np.abs(Ai - (j+1))) >= 0)
  Ap = np.copy(A)
print(A)

Submission status: Wrong Answer

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

def main(A):
  B=[0]*N
  for i in range(N):  #i;座標
    for j in range(N):
      if abs(i-j) <= A[j]:
        B[i]+=1
        #print(i,B[i])
  #print(B)
  A =B
  return A

#print(main(A))
for _ in range(K):
  A=main(A)

print(A)

Submission status: Wrong Answer

Solution code:
import collections

n,k=(int(x) for x in input().split())
a = [int(x) for x in input().split()]

for x in range(k):
    b = []
    for i,j in enumerate(a):
        for l in range(max(i-j,0),min(i+j+1,n)):
            b.append(l)
    c = collections.Counter(b)
    print(b)
    a = c.values()
    
print(" ".join([str(x) for x in a]))

Submission status: Wrong Answer

Solution code:
def main():
    N, K = map(int, input().split())
    A_list = list(map(int, input().split()))

    for _ in range(min(K,40)):
        e_list_1 = [0] * N
        l_1 = [0] * N
        v = 0
        for i,a in enumerate(A_list):
            l_1[i] = v 
            e_list_1[min(i + a, N-1)] += 1
            v = v + 1 - e_list_1[i]
        
        e_list_2 = [0] * N
        v = 0
        for _i,a in enumerate(A_list[::-1]):
            i = N-1-_i
            A_list[i] = l_1[i] + v + 1
            e_list_2[max(i-a, 0)] += 1
            v = v + 1 - e_list_2[i]
        
    print(*A_list)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N,K=list(map(int,input().split(' ')))
A=list(map(int,input().split(' ')))
A2=A
S=[]
if K>=N//5+5:
    print([N]*N)
    exit()
for i in range(K):
    A=A2
    A2=[0]*N
    for i in range(len(A)):
        d=A[i]
        for j in range(d+1):
            if i-j>=0 and j>0:
                A2[i-j]=A2[i-j]+1
            if i+j<N:
                A2[i+j]=A2[i+j]+1

print(A2)

Submission status: Wrong Answer

Solution code:
#! -*- coding: utf-8 -*-

import math

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


def in_range(x, n_min, n_max):
    if n_min <= x <= n_max:
        return True
    else:
        return False


lamps = {n+1: [math.ceil(n+1-ac-0.5) if math.ceil(n+1-ac-0.5) > 1 else 1, math.floor(n+1+ac+0.5)] for n, ac in enumerate(a)}
lamp_counter = {}
temp_list_2 = []

for _ in range(k):
    lamp_counter = {nc+1: 0 for nc in range(n)}

    for key, (start, end) in lamps.items():
        lamp_counter[start] += 1
        lamp_counter[end if end < n else n] -= 1


    temp_list = list(lamp_counter.values())
    temp_list_2 = [temp_list[0]]

    for ii in range(len(temp_list) - 1):
        temp_list_2.append(temp_list_2[ii] + temp_list[ii + 1])
    lamps = {
        n + 1: [math.ceil(n + 1 - ac - 0.5) if math.ceil(n + 1 - ac - 0.5) > 1 else 1, math.floor(n + 1 + ac + 0.5)] for
        n, ac in enumerate(temp_list_2)}


print(*temp_list_2)

Submission status: Wrong Answer

Solution code:
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
if K >= N:
    ans = [N]*N
    print(*ans)
else:
    CA = [0]*N
    for j in range(N):
        CA[max(0,j-A[j]):min(j+A[j]+1,N)] = map(lambda x: x+1,CA[max(0,j-A[j]):min(j+A[j]+1,N)])
    for i in range(K):
        SA = [x - y for (x, y) in zip(CA, A)]
        A = [CA[i] for i in range(N)]
        for j in range(N):
            CA[max(0,j-SA[j]):min(j+SA[j]+1,N)] = map(lambda x: x+1,CA[max(0,j-SA[j]):min(j+SA[j]+1,N)])
    print(*A)

Submission status: Wrong Answer

Solution code:
import math
from collections import defaultdict

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


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


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

print(' '.join(bl))

Submission status: Wrong Answer

Solution code:
i=(input().split())
j=(input().split())

N=i[0]
K=i[1]


e=[]
f=[]

for z in range(int(K)):
    f=[]
    for x in range(int(N)):
        d=[]
        for y in range(int(N)):
            if x == y:
                d.append(1)
            else: 
                if int(j[y]) != 0:
                    if abs(x-y) <= int(j[y]):
                        d.append(int(1))
                    elif abs(x-y) > int(j[y]):
                        d.append(0)
                elif int(j[y]) == 0:
                    d.append(0)
        f.append(sum(d))
    j=f
    
    
print(f)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
if((n+3)//2+1 <= k):
    c = [str(n)]*n
else:
    for i in range(k):
        b = [0]*n
        for j in range(n):
            for k in range(max(0,j-a[j]),min(n-1,j+a[j])+1):
                b[k] += 1
        print(b)
        a = b
    c = [str(a) for a in b]
print(' '.join(c))

Submission status: Wrong Answer

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

a = [0] * N
for k in range(K):

    for i in range(N):
        l = max(0, i - A[i])
        r = A[i] + i + 1
        if r < N - 1:
            a[r] -= 1
        a[l] += 1

    if a[0] == N:
        A = [N] * N
        break

    for j in range(N):
        A[j] = A[j - 1] if j > 0 else 0
        A[j] += a[j]
        a[j] = 0

    # print("k=", k, A)


for i in range(N):
    print(A[i], end="")
    if i < N - 1:
        print(" ", end="")
print()

Submission status: Wrong Answer

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

ans1=[0]*n

for b in range(0,n):
  temp=ans[b]
    
  d=b-temp
  if d <= 0:
    d=0
  e=b+temp
  if e >= n-1:
    e=n-1
  for c in range(d,e+1):
    ans1[c]=ans1[c]+1
    

    
for a in range(0,k-1):
  ans2=ans1
  ans3=[0]*n
  for b in range(0,n):
  	temp=ans1[b]
    
  	d=b-temp
  	if d <= 0:
    	 d=0
  	e=b+temp
  	if e >= n-1:
    	 e=n-1
  	for c in range(d,e+1):
    	 ans3[c]=ans3[c]+1
  ans1=ans3
  

print(ans1)

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int,input().split())
  
a=[0]*n
ans=[0]*n
a=list(map(int,input().split()))
check=math.ceil(math.log2(n))+1
if (k>=20):
  a=[n]*n
  print(" ".join(map(str,a)))
else:
  for _ in range(k):
    ans=[0]*n
    for i in range(n):
      left=max(0,i-a[i])
      right=min(n-1,i+a[i])
      #print(left,right)
      for j in range(left,right+1):
        ans[j]+=1
    a=ans

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

Submission status: Wrong Answer

Solution code:
import sys
from itertools import accumulate
from math import log2
def input(): return sys.stdin.readline().strip()

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

    if 20 <= K:
        ans = [N] * N
        print(" ".join(map(str, ans)))
        return
    
    for _ in range(K):
        B = [0] * (N + 1)
        for i in range(N):
            head = max(i - A[i], 0)
            tail = min(i + A[i] + 1, N)
            B[head] += 1
            B[tail] -= 1
        A = list(accumulate(B))[:N]
    print(" ".join(map(str, A)))
    

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

def main(A):
  B=[0]*N
  for i in range(N):  #i;座標
    for j in range(N):
      if abs(i-j) <= A[j]:
        B[i]+=1
        #print(i,B[i])
  #print(B)
  A =B
  return A

#print(main(A))
for _ in range(K):
  A=main(A)

print(A)

Submission status: Wrong Answer

Solution code:
import copy

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

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

for p in range(k):
  tmp=[]
  tmp.append(copy.deepcopy(a))
  for i in range(len(a)):
    x=0
    for j in range(len(tmp[0])):
      if abs(i-j) < tmp[0][j] + 0.5:
        x=x+1
    a[i]=x
print(a)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,k = map(int,input().split())
a = list(map(int,input().split()))
if k >= n:
    print(n,end=' ')
else:
    ans = np.array([0 for i in range(n)])
    for j in range(k):
        if j >= 1:
            a = ans
            ans=np.array([0 for i in range(n)])
        for i in range(n):
            sup = i+a[i]
            inf = i-a[i]
            if inf == sup:
                ans[inf] += 1
            elif 0 <= inf and sup <= n-1:
                ans[inf:sup+1] += 1
            elif 0 > inf and sup <= n-1:
                ans[:sup+1] += 1
            elif 0 <= inf and sup > n-1:
                ans[inf:] += 1
            else:
                ans += 1
    for i in range(n):
        print(ans[i],end=' ')

Submission status: Wrong Answer

Solution code:
N,K,*A = map(int, open(0).read().split())
                                         
for _ in range(K):                       
    X = [1 for _ in range(N)]            
    for i, d in enumerate(A):            
        for j in range(1, d + 1):        
            k = i + j                    
            if 0 <= k < N:               
                X[k] += 1                
            k = i - j                    
            if 0 <= k < N:               
                X[k] += 1                
    A = X                                
                                         
print(A)

Submission status: Wrong Answer

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

for time in range(K):
  if all([max(i, N - i - 1) <= a for i, a in enumerate(A)]):
    for i in range(N):
      A[i] += K - time
    break
  
  for i in range(N):
    for j in range(-A[i], A[i]+1):
      if i + j in range(N):
        NEW_A[i+j] += 1

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

print(*A, sep=' ')

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

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] * N] * (K + 1)
lamps[0] = A

lamps = np.array(lamps)

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

for i in range(K):
    if lamps[i][-1] == N:
        if np.all(lamps[i] == np.ones(N) * N):
            ans = [str(N)] * N
            print(" ".join(ans))
            sys.exit()
    for j in range(N):
        tmp = lamps[i][j]
        if tmp == 0:
            lamps[i+1][j] += 1
        else:
            lamps[i + 1][max(0, j - tmp):min(N + 1, j + tmp) + 1] += 1

ans = lamps[-1].tolist()
ans = map(str, ans)
print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
A = [int(i) for i in input().split()]
#print(A)
B =[0]* n
templist = []
for _ in range(k):
    for i in range(n):
        temp = A[i]
        templist = [0]  
        for j in range(1, temp+1):
            templist.append(j)
            templist.append(-j)
        #print(templist)
        for p in templist:
            if i + p>=0 and i + p <= n-1:
                #print(i + p)
                B[i + p] += 1
            else:
                continue
    
    #print("B:",B)
    A = B
    B = [0]* n
    
print(A)

Submission status: Wrong Answer

Solution code:
num=input().split()
num=[int(i) for i in num]
line=input().split()
line=[int(i) for i in line]


for w in range(num[1]):
  light=[1 for j in range(num[0])]
  for x in range(num[0]):
    y=line[x]
    ran=list(range(x-y,x+y+1))
    if x-y<0:
      del ran[0:-x+y]
    if x+y+1>num[0]:
      del ran[-(x+y+1-num[0]):]
    for z in ran:
      if x==z:
        continue
      else:
        light[z]+=1
  line=light
  
print(light)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
d_ls=[int(z) for z in input().split()]

b=[0]*n
for kk in range(k):
  for i,d in enumerate(d_ls):
    i_front=i+d+0.5
    i_back=i-d-0.5
    for ii,dd in enumerate(d_ls):
      if i_front>=ii>=i_back:
        b[ii]+=1
  for iii,bbb in enumerate(b):
    d_ls[iii]=bbb

bl=[str(a) for a in b]
bl=" ".join(bl)
print(bl)

Submission status: Wrong Answer

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


class RAQ():
    
    def __init__(self, size):
        """初期化"""
        self.size = size
        n = 2 ** ((size-1).bit_length())
        treesize = n * 2
        st = [0] * treesize
        self.st = st
        self.offset = len(st) // 2

    @classmethod
    def from_array(cls, a):
        st = cls(len(a))
        for i, x in enumerate(a):
            st.add(i, i+1, x)
        return st

    def _add_topdown(self, a, b, value, k=1, l=0, r=-1):
        """区間[a, b) に対する加算
        k: 着目しているノード (1-indexed)
        l: 探索区間 st[l, r) の左端 (0-indexed)
        r: 探索区間 st[l, r) の右端 (0-indexed)
        """
        if r == -1:
            r = self.offset
        if r <= a or b <= l:
            return
        if l == r - 1:
            self.st[k] += value
            return
        if a <= l and r <= b:
            self.st[k] += value
            return
        mid = (l + r) // 2
        self._add(a, b, value, k * 2, l, mid)
        self._add(a, b, value, k * 2 + 1, mid, r)

    def _add_bottomup(self, a, b, value):
        """区間[a, b) に対する加算
        """
        a += self.offset
        b += self.offset - 1
        while a < b:
            if a & 1:
                self.st[a] += value
                a += 1
            a >>= 1
            if not b & 1:
                self.st[b] += value
                b -= 1
            b >>= 1
        if a == b:
            self.st[a] += value

    def add(self, a, b, value):
        """区間[a, b) に対する加算"""
        if a > b:
            raise ValueError("a must be less than equal b.")
        return self._add_bottomup(a, b, value)

    def get(self, key):
        """値の取得"""
        offset = len(self.st) // 2
        k = offset + key
        v = self.st[k]
        k >>= 1
        while k > 0:
            v += self.st[k]
            k >>= 1
        return v


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


def solve(N, K, A):
    KL = int(math.log2(N) * 2) + 1
    if K > KL:
        print(' '.join([str(N)] * N))
        return
    raq = RAQ.from_array(A)
    a = [0 for i in range(N)]

    for k in range(min(K, KL)):
        for i in range(N):
            a[i] = raq.get(i)
            raq.add(i, i+1, -a[i])
        for i in range(N):
            l = max(0, i-a[i])
            r = min(N, i+1+a[i])
            raq.add(l, r, 1)
    print(' '.join([str(raq.get(i)) for i in range(N)]))


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Wrong Answer

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

if K%2 == 1:
    T = [0]*N
    for i in range(N):
        for j in range(max(0,i-A[i]), min(N-1, i+A[i])+1):
            T[j] += 1
    A, T = T, A

for _ in range(int(K/2)-1):
    T = [0]*N
    for i in range(N):
        for j in range(max(0,i-A[i]), min(N-1, i+A[i])+1):
            T[j] += 1
    A, T = T, A
    if min(A) == N: break

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


print(*A)

Submission status: Wrong Answer

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

dp = [[0] * 2 for i in range(n)] # 光の範囲

ans = l[:] # 各電球の光の強さ, including '0'
for j in range(n):
    dp[j][0] = (j+1 - ans[j] - 0.5)
    dp[j][1] = (j+1 + ans[j] + 0.5)

for i in range(k):
    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
    for j in range(n):
        dp[j][0] = (j+1 - ans[j] - 0.5)
        dp[j][1] = (j+1 + ans[j] + 0.5)

print(ans)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
lump = list(map(int, input().split()))
for i in range(k):
    lumpk = lump.copy()
    for x in range(n):
        d = lump[x]
        if d == 0:
            pass
        else:
            if x - d  < 0:
                if x + d + 1 > n - 1:
                    for j in range(n):
                        lumpk[j] += 1
                else:
                    for j in range(x + d + 1):
                        lumpk[j] +=1
            else:
                if x + d + 1 > n - 1:
                    for j in range(x - d -1, n):
                        lumpk[j] += 1
                else:
                    for j in range(x - d  - 1, x + d + 1):
                        lumpk[j] +=1
    lump = lumpk
print(lump)

Submission status: Wrong Answer

Solution code:
def update(a, n):
    plus = []
    minus = []
    for i in range(n):
        plus.append(i + 1 - a[i])
        minus.append(i + 1 + a[i])

    plus_ptr = 0
    minus_ptr = 0
    cnt = 0

    is_continue = False

    for i in range(n):
        while plus_ptr < len(plus) and plus[plus_ptr] <= (i+1):
            cnt += 1
            plus_ptr += 1
        while minus_ptr < len(minus) and minus[minus_ptr] < (i+1):
            cnt -= 1
            minus_ptr += 1

        if a[i] != cnt:
            is_continue = True

        a[i] = cnt

    return is_continue


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

for i in range(k):
    ret = update(a, n)
    if not ret:
        break

print(' '.join(list(map(str, 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
    for x in range(N):
        for b in range(-A[x], A[x]+1):
            if x+b >= 0 and x+b < N:
                B[x+b] += 1
    A = B
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))

thre = 0
for i in range(N):
    if A[i] < i:
        thre = max(thre, i-A[i])

if K >= min(math.log(N, 2)//2, thre):
        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:
N, K = map(int, input().split())
A = list(map(int, input().split()))

for i in range(K):
    B = [0] * N
    for i in range(N):
        if A[i] > 0:
            d = A[i]
            B[i] += 1
            for j in range(d + 1):
                if i + j + 1 < N:
                    B[i + j + 1] += 1
                if i > j:
                    B[i - j - 1] += 1
    for i in range(N):
        A[i] = B[i]


print(A)

Submission status: Wrong Answer

Solution code:
def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    dict = {}
    temp = {}
    for i in range(N):
        dict[i+1] = A[i]
        temp[i+1] = 0

    for j in range(K):
        if dict[1] == N:
            ans = list(dict.values())
            ans2 = str(ans[0])
            for i in range(1,N):
                ans2 += (' ' + str(ans[i]))
            return(ans2)

        for h in range(1,N+1):
            temp2 = dict[h]
            for n in range(h-temp2,h+temp2+1):
                if n <= 0:
                    continue
                elif n > N:
                    break
                else:
                    temp[n] += 1

        for i in range(1,N+1):
            dict[i] = temp[i]
            temp[i] = 0

    ans = list(dict.values())
    ans2 = str(ans[0])
    for i in range(1,N):
        ans2 += (' ' + str(ans[i]))
    return(ans2)

print(main())

Submission status: Wrong Answer

Solution code:
import math
import numpy as np

def cal_B(a_list):
    b_list = [0]*N
    for i in range(N):
        temp = np.zeros(N, dtype=int)
        min_x = max(math.ceil(i - a_list[i] - 0.5), 0)
        max_x = min(math.floor(i + a_list[i] + 0.5), N-1)
        
        temp[min_x : max_x+1] = 1
        b_list += temp
    return b_list

if __name__ == "__main__":
    N, K = map(int, input().split())
    A_list = np.array(list(map(int, input().split())))
    B_list = cal_B(A_list)
    
    for _ in range(K - 1):
        B_list = cal_B(B_list)

    print(B_list)

Submission status: Wrong Answer

Solution code:
n,k=list(map(int,input().split()))
A=list(map(int,input().split()))
if max(A)==0:
  for y in range(n):
    print(0,end=" ")
  exit()
if k>=n**2:
  for y in range(n):
    print(n,end=" ")
  exit()
def sousa(a,k):
  B=[0]*len(a)
  for i in range(1,len(a)+1):#1~N
    if a[i-1]!=0:
      for j in range(i-a[i-1],i+a[i-1]+1):
        if j>0 and j<=len(a):
          B[j-1]+=1#0~N-1
    if min(B)>=n:
      return B
  k-=1
  return B if k==0 else sousa(B,k)
for x in sousa(A,k):
  print(x,end=" ")

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))

thre = 0
for i in range(N):
    if A[i] < i:
        thre = max(thre, i-A[i])

if K >= min(2 * math.log(N, 2), thre):
        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()