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 copy
import math

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

if k>=math.sqrt(2*n)+1:
    tmp=[]
    for i in range(len(a)):
        tmp.append(n)
else:
    for i in range(k):
        tmp=[]
        for i in range(len(a)):
            tmp.append(1)
        for num, i in enumerate(a):
            for j in range(i):
                j+=1
                if  num+j<len(a):
                    tmp[num+j]+=1
                if 0<=num-j:
                    tmp[num-j]+=1
        a=tmp

ans=""
for i in a:
    ans+=str(i)+" "
print(ans[0:-1])

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    if K >= 30: A = [N] * N
    else:
        for k in range(K):
            nextL = [0] * (N + 1)
            for i, a in enumerate(A):
               left = max(0, i - a)
               right = min(N, i + a + 1)
               nextL[left] += 1
               nextL[right] -= 1
            #print(nextL)
            A[0] = nextL[0]
            for i in range(1, N):
                A[i] = A[i-1] + nextL[i]
    print(*A, sep=" ")
    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
A = list(map(int, input().split()))
B = [0]*N
#print(B)
for q in range(K):
    
    for i in range(N):
        if A[i] == 0:
            B[i] += 1
        else:
            B[i] += 1
            cover = A[i]
            for j in range(1,cover+1):
#                print(j)
                if 0 <= i-j <= N-1:
                    B[i-j] += 1
                if 0 <= i+j <= N-1:
                    B[i+j] += 1
    A = B
    B = [0]*N
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(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
        
        
   


print(A)

Submission status: Wrong Answer

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

def main():
    n,k = map(int, input().split())
    a = list(map(int, input().split()))
    tnp = min(a)
    c = 0
    for i in range(k):
        #print(tnp)
        if (tnp==0):
            tnp = 1
            continue
        tnp = tnp*2
        if tnp >= n:
            c += 1
            if (c==2):
                ans = [n]*n
                print(*ans)
                exit()
    #print(tnp)
    for i in range(k):
        b = [0]*n
        for i in range(n):
            l = i-a[i]
            r = i+a[i]
            #print(l,r)
            b[max(l,0)] += 1
            if (r<n-1):
                b[r+1] -= 1
            #print(b)
    
        for i in range(1,n):
            b[i] = b[i-1] + b[i]
        a = b
        
    print(*b)
    
    
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy
import math
def main():
    N, K = map(int, input().split())
    a = [float(i) for i in input().split()]
    A = [0] * (N + 1)
    for i in range(1, N):
        A[i] = a[i - 1]
    for _ in range(K):
        count = [0] * (N + 1)
        for i in range(1, N+1):
            left_d = math.ceil(i - A[i] - 0.5)
            right_d =  math.floor(i + A[i] + 0.5)
            if left_d < 1:
                left_d = 1
            if right_d > N:
                right_d = N
            for j in range(left_d, right_d+1):
                count[j] += 1
        A = copy.copy(count)
        flag = True
        for i in range(1, N+1):
            if A[i] != N:
                flag = False
                break
        if flag:
            break
    print(A[1:])
            



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    if K >= 20: A = [N] * N
    else:
        for k in range(K):
            nextL = [0] * (N + 1)
            for i, a in enumerate(A):
               left = max(0, i - a)
               right = min(N, i + a + 1)
               nextL[left] += 1
               nextL[right] -= 1
            #print(nextL)
            A[0] = nextL[0]
            for i in range(1, N):
                A[i] = A[i-1] + nextL[i]
    print(*A, sep=" ")
    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import numpy as np
def solve():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    br = np.zeros(N, dtype=np.int64)


    for i in range(K):
        br = np.zeros(N, dtype=np.int64)
        for ind, rux in enumerate(A):
            br[max(ind-rux,0) : min(ind+rux+1,N+1)] += 1
        print(br)
        A = br



if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import numpy
N,K = map(int,input().split())
A = numpy.fromiter(map(int,input().split()),int)
A_ = numpy.copy(A)
for i in range(K):
    A_ = numpy.zeros(N)
    for j in range(N):
        before = j - A[j]
        after = j + A[j]
        if(before < 0):
            before = 0
        if(after > N-1):
            after = N-1
        A_[int(before):int(after+1)] += 1
    A = numpy.copy(A_)
print(A_)

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

# N = 10 ** 5 * 2
# K = N
# A = [0] * (N+1)
cnt = 0
while A[0] < N and A[-1] < N and cnt < K:
    cnt += 1
    next_A = [0] * (N+1)
    for j in range(N):
        tmp = A[j]
        next_A[min(max(j-tmp, 0), N-1)] += 1
        next_A[min(N, tmp+1+j)] -= 1
    for j in range(N):
        next_A[j+1] += next_A[j]
    next_A.pop()
    A = next_A
print(" ".join([str(i) for i in A]))

Submission status: Wrong Answer

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

import copy
ans=[0]*N
for _ in range(K):
    for i,a in enumerate(A):
        print(max(0,i-a),min(i+a+1,N))
        for x in range(max(0,i-a),min(i+a+1,N)):
            ans[x]+=1
        print(ans)
    A=copy.copy(ans)
    ans=[0]*N
print(*ans)

Submission status: Wrong Answer

Solution code:
N,K= map(int,input().split())
A = list(map(int,input().split()))
T = [0 for _ in range(N)]
for t in range(K):
    for i in range(N):
        for j in range(max(i-A[i],0),min(N-1,i+A[i]+1)):
            T[j] += 1
    for i in range(N):
        A[i]=T[i]
        T[i]=0
A=[str(a) for a in A]
A=' '.join(A)
print(A)

Submission status: Wrong Answer

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

for i in range(K):
    a=[0 for i in range(N+1)]
    for j in range(N):
        a[max(0,j-L1[j])]+=1
        a[min(N,j+L1[j]+1)]-=1
        #print(a[:N])
    L2=[a[0]]
    for j in range(1,N):
        L2.append(L2[-1]+a[j])
    #print(L2)
    if L2==L1[:N]:
        print(L2)
        exit()
    else:
        L1=L2+[0]
print(*L2)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K=map(int,input().split())
A=list(map(int,input().split()))
A=np.array(A)
for _ in range(K):
    A_temp=np.array([0]*N)
    for i in range(N):
        if A[i]>0:
            #print(max(0,i-A[i]-1),min(N,i+A[i]+1 +1))
            A_temp[max(0,i-A[i]-1):min(N,i+A[i]+1 +1)] +=1
            #print(A_temp)
    A=A_temp
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-1) > n:
    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):
        count = 0
        
        if a_n[j] == n:
            result[j] =n
            continue
        for l in range(n):
            if l > j:
                if l-a_n[l]-0.5<j:
                    count += 1
            elif l < j:
                if l+a_n[l]+0.5>j:
                    count += 1
            else:
                count += 1
        result[j] =count
    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:
# 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

if A == [0] * N:
    for i in range(N):
        print("0", end = " ")
    print("")
    sys.exit()

lamps = np.array(lamps)

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

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

    return dict

print(main())

Submission status: Wrong Answer

Solution code:
num_bulb, count = map(lambda x: int(x), input().split())
brightness = list(map(lambda x: int(x), input().split()))

print(brightness)

for i in range(count):
    next_brightness = []
    # それぞれの電球について
    for j in range(num_bulb):
        next_brightness.append(0)
        # それをテラス電球を調べる
        for k in range(num_bulb):
          if abs(j - k) < brightness[k] + 0.5:
            next_brightness[j] += 1

print(' '.join(list(map(lambda x: str(x), next_brightness))))

Submission status: Wrong Answer

Solution code:
import numpy as np

# Calculate intensity
N, K = [int(v) for v in input().split(" ")]
A_arr = np.array([int(v) for v in input().split(" ")])
step = np.arange(len(A_arr))
print("0")
exit()
def Luminate(A_arr, i):
  isLuminated = np.abs(step - i) < A_arr
  return isLuminated

def get_Intensity(A_arr):
  return np.array([np.sum(Luminate(A_arr, i)) for i in range(len(A_arr))])
Intensity = A_arr
for i in range(K):
  Intensity = get_Intensity(Intensity+1)
  if np.sum(Intensity) == N**2:
    break
print(" ".join([str(v) for v in Intensity]))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]*n
for l in range(k):
  b=[0]*n
  count=0
  for i in range(n):
    c=a[i]
    if c==n:
      count+=1
    if count==n:
      p=[n]*n
      print(*p)
      exit()
    b[i]+=1
    if c>0:
      for j in range(c):
        if (i-c+j)<0 and (i+c-j)>=n:
          continue
        elif (i-c+j)<0:
          b[i+c-j]+=1
        elif (i+c-j)>=n:
          b[i-c+j]+=1
        else:
          b[i-c+j]+=1
          b[i+c-j]+=1
  a=b
  
  print(*a)
print(*a)

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):
    if a[0] >= N:
        break
    a = [0] * N
    for i in range(N):
        a[max(0, i - A[i])] += 1
        if N - 1 >= (A[i] + i + 1):
            a[A[i] + i + 1] -= 1
    for j in range(N):
        A[j] = A[j - 1] if j > 0 else 0
        A[j] += a[j]
    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:
import numpy as np
n, k = map(int, input().split())
a = list(map(int, input().split()))
bb = np.array(a, dtype=np.int64)
# print(bb)

for i in range(k):
    #d = [0] * n
    d = np.zeros(n, dtype=np.int64)
    #temp = bb
    for j in range(1, n+1):
        left = j - bb[j - 1]
        # print(left)
        if (left < 0):
            left = 0
        right = j + bb[j - 1]
        #print('R: ',right)
        if (right > n):
            right = n
        #print('L&R: ', left, right)
        if (left == right):
            d[int(left - 1)] += 1
        else:
            d[int(left): int(right + 1)] += 1
        # print(d)

    bb = d

ans = [str(i) for i in bb]
# print(ans)
print(' '.join(ans))

#s = ','.join(l)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
List = list(map(int, input().split()))
strength = [1]*N
for k in range (K):
  for i in range(N):
    if List[i] == 0:
      pass
    else:
      for j in range(1,List[i]+1):
        print(i-j ,i+j)
        if i-j<0 and (i+j > N or i + j == N):
          pass
        elif i-j<0 and i+j <N:
          strength[i+j] += 1
        elif i-j>=0 and (i+j > N or i + j == N):
          strength[i-j] += 1
        else:
          strength[i-j] += 1
          strength[i+j] += 1
      #print(List,strength)
  List = strength
  strength = [1]*N
print(*List)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
Ai = input().split()
Bi = [int(i) for i in Ai]


for n in range(K):
    li = [0 for i in range(N)]
    for i,x in enumerate(Bi):
        li[i] += 1
        for l in range(1,x+1):
            if i - l >= 0:
                li[i-l] += 1
            if i + l <= N - 1:
                li[i+l] += 1
    Bi = li
print(li)

Submission status: Wrong Answer

Solution code:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]


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

    if sum(a)==0:
        lst=[0]*n
        print(*lst)
        quit()
    while k:
        lst=[1]*n
        dic={}
        cnt=0
        for i in range(n):
            lst[i]+=cnt
            if i in dic:
                cnt-=dic[i]
            if a[i]>0:
                if not i+a[i] in dic:
                    dic[i+a[i]]=1
                else:
                    dic[i+a[i]]+=1
                cnt+=1

        dic={}
        cnt=0
        for i in range(n)[::-1]:
            lst[i]+=cnt
            if i in dic:
                cnt-=dic[i]
            if a[i]>0:
                if not i-a[i] in dic:
                    dic[i-a[i]]=1
                else:
                    dic[i-a[i]]+=1
                cnt+=1
        k-=1
        if sum(lst)==n*n:
            break
        # print(k)
        a=lst[:]

    print(*lst)

main()

Submission status: Wrong Answer

Solution code:
n_k = input()
all_a = input()
n_k_list = n_k.split()
n = int(n_k_list[0])
k = int(n_k_list[1])
a_list = all_a.split()
b_list = []
for a in a_list:
  strength_a = 1 - int(a)
  cnt = 0
  for i in range(k):
    d = abs(strength_a - i)
    if d > 0.5:
      pass
    else:
      cnt += 1
  b_list.append(cnt)
b_str = [str(y) for y in b_list]
b_str = ' '.join(b_str)
print(b_str)

Submission status: Wrong Answer

Solution code:
import sys
n,k=map(int,input().split())
a=list(map(int,input().split()))
if k>n-2:
  for i in range(n):
    a[i]=n
    sys.exit()
for i in range(k):
  b=[0]*n
  
  for j in range(n):
    for m in range(j-a[j],j+a[j]+1):
      if 0<=m<=n-1:
        b[m]=b[m]+1
  a=b
for i in a:
  print(i,end=' ')

Submission status: Wrong Answer

Solution code:
def main():
    N,K = map(int,input().split())
    FA = list(map(int,input().split()))
    A = [0]*N
    ANS = [N]*N
    for i in range(N):
        mi = max(0,i-FA[i])
        ma = min(N-1,i+FA[i])
        for i in range(mi,ma+1):
            A[i] +=1

    print(*A)
    for i in range(N):
        mi = i-A[i]-K+1
        ma = i+A[i]+K-1
        if mi>=0:
            for j in range(0,mi+1):
                ANS[j] -=1
        if ma<=N-1:
            for j in range(ma,N):
                ANS[j] -=1


    if K == 1:
        print(*A)
    else:
        print(*ANS)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if (k>15):
  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:
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=[0]*N

sousa=0

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

print(A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import copy
import math

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

if k>=math.sqrt(n)*2:
    tmp=[]
    for i in range(len(a)):
        tmp.append(n)
else:
    for i in range(k):
        tmp=[]
        for i in range(len(a)):
            tmp.append(1)
        for num, i in enumerate(a):
            for j in range(i):
                j+=1
                if  num+j<len(a):
                    tmp[num+j]+=1
                if 0<=num-j:
                    tmp[num-j]+=1
        a=tmp

ans=""
for i in a:
    ans+=str(i)+" "
print(ans[0:-1])

Submission status: Wrong Answer

Solution code:
import copy

NK = input().split()
A = input().split()
N = int(NK[0])
K = int(NK[1])
AA = [0] * N
for i in range(N):
    AA[i] = int(A[i])
BB = [0] * N
for i in range(K):
    for j in range(N):
        # print("before adding")
        # print(AA)
        for k in range(j - AA[j], j + AA[j]+1):
            # print(k)
            if k >= 0 and k < N:
                BB[k]+= 1
        # print(BB)
    AA=copy.copy(BB)
    if i < K-1:
        BB = [0] * N
print(BB)

Submission status: Wrong Answer

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

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

def calc(A):
    B = [0] * len(A)
    for i in range(len(A)):
        B[max(0,i - A[i])] += 1
        if i + A[i] + 1 < len(A):
            B[i + A[i] + 1] -= 1
    for i in range(1,len(B)):
        B[i] = B[i - 1] + B[i]
    return B

for i in range(K):
  A = calc(A)
  if len(set(A)) == 1:
    print(*A)
    break
else:
  print(*A)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
now = list(mapint())
from itertools import accumulate
iteration = min(N.bit_length()*2, K)
for k in range(iteration):
    nx = [0]*N
    for i, a in enumerate(now):
        nx[max(0, i-a)] += 1
        if i+a+1<N:
            nx[i+a+1] -= 1
    nx = list(accumulate(nx))
    now = nx[:]
print(*now)

Submission status: Wrong Answer

Solution code:
kosuu, kaisuu = map(int, input().split(" "))
a=list(map(int, input().split(" ")))

for i in range(kaisuu):
  temp=[]
  for j in range(kosuu):
    count=0
    for k in range(kosuu):
      if max(j, k)-min(j, k) <= a[k]:
        count += 1
    temp.append(count)
  if a != temp:
    a=temp
  else:
    break
print(a)

Submission status: Wrong Answer

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

for i in range(K):
  nextA = [0 for _ in range(N)]
  for j in range(N):
    lamps = [int(max(0,j-As[j])<=k<=j+As[j]) for k in range(N)]
    nextA = [x+y for x, y in zip(nextA, lamps)]
  As = nextA
  print(As)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

n, k = map(int, input().split())
a = np.array(list(map(int, input().split())), dtype=np.uint16)

for _ in range(k):
    b = np.zeros(n, dtype=np.uint16)
    for i, aa in enumerate(a):
        b[max(0, i-aa):i+aa+1] += 1
    a = b
    if np.min(a) == np.max(a):
        break

print(' '.join(np.array(a, dtype=str)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K=map(int, input().split())
AA=[int(i) for i in list(input().split())]
A=np.array(AA)
B=np.zeros(N).astype("i8")
for i in range(K):
  for j in range(N):
    B[max(j-A[j],0):min(j+A[j]+1,N)]+=1
  A=B
  B=np.zeros(N).astype("i8")
print(A)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=np.ones(N)
for i in range(K):
  if i==0:
    for j in range(N):
      x=A[j]
      if x>0:
        for k in range(1,int(x)+1):
          if j+k<=N-1:
          	B[j+k]+=1
          if j-k>=0:
            B[j-k]+=1
  else:
    A=B
    B=np.ones(N)
    for j in range(N):
      x=A[j]
      if x>0:
        for k in range(1,int(x)+1):
          if j+k<=N-1:
       	    B[j+k]+=1
          if j-k>=0:
            B[j-k]+=1
print(B)

Submission status: Wrong Answer

Solution code:
import math

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)
                #print(low)
                #print(high)
                while low <= high:
                    B[low] += 1
                    low += 1
                B[i] -= 1
        A = B


    print(A)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import heapq

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

for _ in range(k):
    finish=True
    start=[]
    startInd=0
    end=[]
    endInd=0
    for i in range(n):
        if A[i]!=n:
            finish=False
        heapq.heappush(start,i-A[i])
        heapq.heappush(end,i+A[i])
    if finish:
        break
    # update ans
    cnt=0
    for i in range(n):
        while startInd<n and start[startInd]<=i:
            cnt+=1
            startInd+=1
        A[i]=cnt
        while endInd<n and end[endInd]<=i:
            endInd+=1
            cnt-=1

print(A)

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

Submission status: Wrong Answer

Solution code:
num_bulb, count = map(lambda x: int(x), input().split())
brightness = list(map(lambda x: int(x), input().split()))


for i in range(count):
  next_brightness = []
  for j in range(num_bulb):
    next_brightness.append(0)
    if abs(j - i) < brightness[j] + 0.5:
      next_brightness[j] += 1
        
print(' '.join(list(map(lambda x: str(x), next_brightness))))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
width = [0 for _ in range(N)]

for k in range(K):
    for i in range(N):
        if i-A[i]-0.5 < 0:
            left = int(i-A[i]-0.5)
        else:
            left = int(i-A[i]-0.5) + 1
        right = int(i+A[i]+0.5)
        if left < 0:
            left = 0
        if right > N-1:
            right = N - 1
        width[left:right+1] = map(lambda x: x+1, width[left:right+1])
    A = width.copy()
    width = [0 for _ in range(N)]

print(A)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
if N > K:
    print(" ".join([str(N)]*K))
else:
    for _ in range(K):
        B = [1]*N
        for i in range(N):
            for j in range(1, A[i]+1):
                if i-j >= 0:
                    B[i-j] += 1
                if i+j < N:
                    B[i+j] += 1
        if A == B:
            break
        A = B

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

Submission status: Wrong Answer

Solution code:
import math

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


for p in range(k):
    ac = [0 for _ in range(n)]
    for i in range(n):
        range_l = math.ceil(i - a[i] - 0.5)
        range_r = math.floor(i + a[i] + 0.5)
        if range_l < 0:
            range_l = 0
        if range_r > n-1:
            range_r = n-1
        for j in range(range_l,range_r + 1):
            ac[j] += 1
    a = ac

print(a)

Submission status: Wrong Answer

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

if n<=k:
    print([n]*n)

Submission status: Wrong Answer

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

for z in range(K):
  #print("############### ",z,"回目 #############")
  A_range = list() #照らしてる範囲のリスト
  for i in range(1,len(A)+1):
    i_range = list() #i番目のライトが照らす範囲
    light = A[i-1]
    i_range = [i - light - 0.5,i + light + 0.5]
    A_range.append(i_range)
  #print(A_range)
  i_count = [0]*len(A) #座標iを照らすライトの数
  for i in range(1,len(A)+1):
    #print("i:",i)
    for j in range(len(A)):
      #print(A_range[j])
      if A_range[j][0] <= i and A_range[j][1] >= i:
        i_count[i-1] += 1
    A[i-1] = i_count[i-1]
print(A)

Submission status: Wrong Answer

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

for i in range(k):
    now = [0]*n

    for j in range(n):
        x = li[j]
        now[max(0,j-x)] += 1
        if j+x+1 < n:
            now[j+x+1] -= 1
    
    for j in range(n-1):
        now[j+1] += now[j]

    li = now
    if min(li) >= n-1:
        break

for j in range(n):
    li[j] += (n-1)*(k-1-i)

print(*li)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = lr()
# ある回数から先は全ての電球にNを足す
for _ in range(min(K, 10)):
    next = [0] * N
    for i in range(N):
        x = A[i]
        for j in range(max(0, i-x), min(N-1, i+x)+1):
            next[j] += 1
    A = next

print(*A)