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:
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 = additional
    for i, intense in enumerate(intense_counters):
        if i == 0:
            continue
        if intense == n:
            counter += 1

        intense += additional
        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):
                if 0 < lighted_position and lighted_position <= n:
                    new_intense_counters[lighted_position] += 1
    if counter == n:
        # max_intense = True
        break
    intense_counters = new_intense_counters
    additional = add_all
    add_all = 0


print(" ".join(list(map(str, intense_counters[1:]))))

Submission status: Wrong Answer

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

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

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


while k > 0:
  b = [0 for i in range(n)]
  for i in range(n):
    for j in range(n):
      aj = a[j]
      if j - aj - 0.5 < i and i < j + aj + 0.5:
        b[i] += 1
  a = copy.copy(b)
  k -= 1
        
for i in range(n):
  print(b[i], ',', end = '')

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 log2(N) + 1 <= 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(map(int,input().split()))
ans_list = list()
for n in range(K):
  for i in range(N):
    count = 1
    if i != N -1:
      j = i +1
      while i+1 >= j+1 - A[j] -0.5:
        j +=1
        count += 1
        if j == N:
          break
    if i != 0:
      k = i -1
      while i+1 <= k+1 + A[k] +0.5:
        k -=1
        count += 1
        if k == -1:
          break
    ans_list.append(count)
  A = tuple(ans_list)
  ans_list.clear()
print(list(A))

Submission status: Wrong Answer

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


for i in range(1, k+1):
    tmp_list = [0 for i in range(n)]
    for j in range(n):
        tmp_list[j] += 1
        a = a_list[j]
        if j - a < 0:
            for k in range(j):
                tmp_list[k] += 1
        else:
            for k in range(j-a, j):
                tmp_list[k] += 1
        if j + a > n - 1:
            for k in range(j + 1, n):
                tmp_list[k] += 1
        else:
            for k in range(j + 1, j + a + 1):
                tmp_list[k] += 1
    a_list = tmp_list
    #print(tmp_list)
print(a_list)

Submission status: Wrong Answer

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

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

for i in range(k):
  data = solve(data)
  if n**2 <= sum(data):
    break

print(data)

Submission status: Wrong Answer

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

for i in range(k):
  for j in range(n):
    for k in range(n):
      if a[k] >= abs(k-j):
        b[j] += 1
    if a[0] == n:
      count += 1
    if count ==2:
      break  
  else:
    a = b  
    b = [0]*n
    continue   
  break
  
print(*a)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K=map(int,input().split())
A=np.array(list(map(int,input().split())))
B=np.zeros(N)
def abs(x):
  if x<0:
    return -x
  else:
    return x

if K>30:
  A=np.ones(N)*N
else:
  for k in range(K):
    for i in range(N):
      B+=np.array([1 if abs(j-i)<=A[i] else 0 for j in range(N)])
    A=B
    B=np.zeros(N)

for i in list(map(int,A)):
  print(i,end=" ")

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
A.insert(0, 0)
B = [0] * (N+1)

def operation():
  global A, B, N
  for i in range(1, N+1):
    left = math.ceil(i - A[i] - 0.5)
    right = math.floor(i + A[i] + 0.5)
    if left < 1:
      left = 1
    if right > N:
      right = N
    for j in range(left, right+1):
      B[j] += 1


operation()

#print(A)
#print(B)

for _ in range(K):
  for i in range(1, N+1):
    if A[i] != B[i]:
      A[i] = B[i]
    B[i] = 0
  operation()

print(A[1:])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
tmp = [0] * n
for i in range(n):
  left = i-a[i]-k+1 if i-a[i]-k+1 >= 0 else 0
  right = i+a[i]+k-1 if i+a[i]+k-1 <= n-1 else n-1
  for j in range(left, right+1):
    tmp[j] += 1
print(' '.join(map(str, tmp)))

Submission status: Wrong Answer

Solution code:
import copy

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


while k > 0:
  b = [0 for i in range(n)]
  for i in range(n):
    for j in range(n):
      if j - a[j] - 0.5 < i and i < j + a[j] + 0.5:
        b[i] += 1
  a = copy.copy(b)
  k -= 1
        
for i in range(n):
  print(b[i], ',', end = '')

Submission status: Wrong Answer

Solution code:
# C - Lamps
N,K = map(int,input().split())
A = list(map(int,input().split()))
if K>=20 or 2**(K-1)>=N:
    for i in range(N):
        print(N,end=' ')
    print('\n')
else:
    for k in range(K):
        new_A = [0]*N
        for i in range(N):
            s = max(0,i-A[i])
            t = min(N,i+A[i]+1)
            for j in range(s,t):
                new_A[j] += 1
        A = new_A[:]
    for i in range(N):
        print(A[i],end=' ')
    print('\n')

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

    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
        a[i] = cnt


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

k = min(k, 120)

for i in range(k):
    update(a, n)

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

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**7:
    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:
def main():
    number, operations = [int(x) for x in input().split()]
    dists = [int(x) for x in input().split()]

    # number = 635
    # dists = [1] * number
    # operations = number
    if number >= 3000 and operations >= 25:
        print(*([number] * number))
        return
    elif number >= 1000 and operations >= 21:
        print(*([number] * number))
        return
    elif number >= 625 and operations >= 20:
        print(*([number] * number))
        return

    for xx in range(operations):
        dists_new = [0] * number
        for i, d in enumerate(dists):
            start = max(0, i - d)
            end = min(i + d, number - 1)
            for j in range(start, end + 1):
                dists_new[j] += 1
        dists = dists_new
        if min(dists) == number:
            # すべての光が両端まで届く，変化しなくなる。
            print('Over', xx)
            break

    print(*dists)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,k,*a=map(int,open(0).read().split())
r=range(n)
while k:
 k-=1;b=[0]*-~n
 for i in r:t=a[i];b[max(0,i-t)]+=1;b[min(n,i-~t)]-=1
 for i in r:b[i+1]+=b[i]
 a=b
 if max(a)==n:break
print(*a[:n])

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(2 * math.log2(N))
    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 sys
import copy
# def input(): return sys.stdin.readline().rstrip()
# input = sys.stdin.readline
input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10 ** 7)

N, K = map(int, input().split())
# A = np.array(list(map(int, (input().split()))))
A = list(map(int, (input().split())))
# nd = np.zeros((N,N), dtype=bool)
# print(*A)
for i in range(min(K,N)):
    cnt = [0]*N
    for j in range(N):
        # nd[j, max(j-A[j],0):min(j+A[j]+1,N)] = True
        for k in range(max(j-A[j],0), min(j+A[j]+1,N)):
            cnt[k] += 1
    # print(nd)
    A = copy.copy(cnt)
    print(*A)

print(*A)

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
A.insert(0, 0)
B = [0] * (N+1)

def operation():
  global A, B, N
  for i in range(1, N+1):
    left = math.ceil(i - A[i] - 0.5)
    right = math.floor(i + A[i] + 0.5)
    if left < 1:
      left = 1
    if right > N:
      right = N
    for j in range(left, right+1):
      B[j] += 1


operation()

#print(A)
#print(B)

for _ in range(K):
  for i in range(1, N+1):
    A[i] = B[i]
    B[i] = 0
  operation()

print(A[1:])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for _ in range(K):
    answer = [0 for _ in range(N)]
    for i in range(N):
        minus_area = (i + 1) - A[i] - 0.5
        plus_area = (i + 1) + A[i] + 0.5
        if minus_area < 0.5:
            minus_area = 0.5
        if plus_area > N + 0.5:
            plus_area = N + 0.5
        minus_area += 0.5
        plus_area -= 0.5
        for index in range(int(minus_area) - 1, int(plus_area)):
            answer[index] += 1
    A = answer
    if A == answer:
        break

for a in answer:
    print(a, end=" ")

Submission status: Wrong Answer

Solution code:
import copy

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


while k > 0:
  b = [0 for i in range(n)]
  for i in range(n):
    for j in range(n):
      if j - a[j] - 0.5 < i and i < j + a[j] + 0.5:
        b[i] += 1
        a = copy.copy(b)
  k -= 1
        
for i in range(n):
  print(b[i], ',', end = '')

Submission status: Wrong Answer

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

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for i in range(k):
    m = min(alist)
    if m > len(alist):
        for z in len(alist):
            alist[z] += (k-i)*len(alist)
        break
    new = [0] * n
    for j in range(n):
        distance = j - alist[j]
        if distance < 0:
            distance = 0
        last =  j + alist[j]
        if last > len(alist)-1:
            last = len(alist)-1

        if alist[j] != 0:
            for k in range(distance,last+1):
                new[k] += 1
        else:
            new[j]+=1
    alist = new
    print(*alist)

Submission status: Wrong Answer

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


import sys
import math

if K > 3.5962*math.log(N):
    A = [N]*N
#    print('over')
    print(' '.join(map(str, A)))
    sys.exit()
    

import numpy as np
A = np.array(A, dtype=int)
lenA = len(A)
for i in range(K):
    B = np.zeros(lenA, dtype=int)
#    print(B)
    for j in range(lenA):
        num = A[j]
#        print(j, num)
        B[max(0, j - num): min(lenA, j + num + 1)] += 1
#        print(j, B)
    if np.all(A == B):
#        print('same')
        break
    else:
        A = B
print(i+1)
print(' '.join(map(str, A)))

Submission status: Wrong Answer

Solution code:
n,k,*a=map(int,open(0).read().split())
r=range(n)
while k:
 k-=1;b=[0]*-~n
 for i in r:t=a[i];b[max(0,i-t)]+=1;b[min(n,i-~t)]-=1
 for i in r:b[i+1]+=b[i]
 if max(a:=b[:n])==n:break
print(*a)

Submission status: Wrong Answer

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

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

        X = br.cumsum()
        A = X[:-1]
        #print(A, br)
        if br[0] == N and br[-1] == -N:
            print(A)
            exit()

    print(A)





if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import copy
def resolve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    
    for i in range(K):
        A_next = [0] * len(A)
        for i, a in enumerate(A):
            A_next[i] += 1
            for d in range(1, a+1):
                idx = i - d
                if idx >= 0 and idx < len(A_next):
                    A_next[idx] += 1

                idx = i + d
                if idx >= 0 and idx < len(A_next):
                    A_next[idx] += 1
        A = copy.deepcopy(A_next)

        if min(A) == N:
            break 

    print(A_next)

if __name__ == "__main__":
    resolve()

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)
    if K >= N:
        for i in range(1, N+1):
            A[i] = N
        print(A[1:])
        sys.exit()
    for i in range(1, N+1):
        A[i] = a[i - 1]
    for _ in range(K):
        count = [0] * (N + 1)
        for i in range(1, N+1):
            if A[i] >= N:
                left_d = 1
                right_d = N
            else:
                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
    for i in range(1, N+1):
        if i > 1:
            print(' ', end='')
        print(A[i], end='')
    print()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import copy

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


while k > 0:
  b = [0 for i in range(n)]
  for i in range(n):
    for j in range(n):
      if j - a[j] - 0.5 < i and i < j + a[j] + 0.5:
        b[i] += 1
        a = copy.copy(b)
        k -= 1
        
for i in range(n):
  print(b[i], ',', end = '')

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 > 20:
    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:
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 >= math.log(N, 2) + 1:
        for i in range(N):
            print(N, '', end='')
        print()
        exit()


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

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
A = list(map(int, input().split()))
A2 = [0] * n
A3 = [n] * n

if k > n:
  print(*A3)
else:
  for l in range(k):
    for j in range(n):
      if A[j] == n:
         A2[j] =n
      else:
        for i in range(n):
          if A[i] >= abs(i-j):
             A2[j] += 1
    A = A2
    A2 = [0] * n
    if A == [n]*n:
      break

print(*A)

Submission status: Wrong Answer

Solution code:
import sys
n, k = list(map(lambda x: int(x), input().split(" ")))

# only two list object used
blightNess = list(map(lambda x: int(x), input().split(" ")))
cosu = [1] * n

def increment(x, blight):
    left = x - blight if x - blight > 0 else 0
    right = x + blight if x + blight <= n - 1 else n - 1
    for i in range(left, right + 1):
        if i != x:
            cosu[i] = cosu[i] + 1

def operation(cosu, blightNess):
    cosu = [1] * n
    for i in range(0, n):
        if blightNess[i] != 0:
            increment(i, blightNess[i])

    return cosu
    
for i in range(0, k):
    cosu = operation(cosu, blightNess)
    tmp = blightNess
    blightNess = cosu
    cosu = tmp

print(" ".join(list(map(lambda x:str(x),blightNess))))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
def LI():return list(map(int,input().split()))
def yes():print("YES")
def no():print("NO")

n,k=LI()
a=LI()

if k>10**4 or k>=n or n>10**4:
    ans=[n]*n
    print(*ans)
    exit()


for _ in range(k):
    b=[0]*n
    for i in range(n):
        q=a[i]
        for j in range(i-q,i+q+1):
            if 0<=j<=n-1:
                b[j]+=1
    if a==b:
        print(*a)
        exit()
    
    a=b[:]
print(*a)

Submission status: Wrong Answer

Solution code:
import math


N,K=map(int,input().split())
A=list(map(int,input().split()))
A.insert(0,0)
Atemp=[0 for i in range(len(A))]
#print(Atemp)
flag=1
if 1 in A:
    if len(A)<K:
        Atemp=[len(A)-1 for i in range(len(A))]
    for m in range(1, len(A)):
        print(Atemp[m], end=" ")
    exit()
for i in range(K):
    for j in range(1,len(A)):
        if A[j]==0:
            continue
        start=max(1,j-A[j])
        end=min(len(A),j+A[j]+1)
        for k in range(start,end):
            Atemp[k]+=1

    """
    for l in range(1,int(len(A)/2)):

        if Atemp[l]>abs(len(A)-l):
            flag*=1
        else:
            flag*=0

    for l in range(int(len(A)/2),len(A)):
        if Atemp[l]>l:
            flag*=1
        else:
            flag*=0

    """
    flag=1
    for l in range(1,len(A)):
        if Atemp[l]>=len(A)-1:
            flag*=1
        else:
            flag*=0
    if flag==1:
        A=Atemp.copy()
        break
    A=Atemp.copy()
    Atemp = [0 for p in range(len(A))]
    """
    if flag==1:
        for o in range(1,len(A)):
            A[o]+=(K-i+1)*len(A)
            print(o)
        break
    flag=1
    """

for m in range(1,len(A)):
    print(A[m],end=" ")

Submission status: Wrong Answer

Solution code:
import copy

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

for k in range(K):
  B = [0] * N
  for i in range(N):
    s = i - A[i]
    if s < 0:
      s = 0
    l = i + A[i] + 1
    if l >= N:
      l = N
    for j in range(s, l):
      B[j] += 1
  A = B
    
print(B)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,k = map(int,input(). split ())
a = list(map(int, input().split()))
b = [0] * n
for m in range(k):
    for i in range(n):
        j = a[i]
        # print(j)
        for jj in range(j+1):
            # print(i-jj)
            if jj == 0:
                b[i] += 1
            else:
                if i-jj >= 0:
                    b[i-jj] += 1
                if n-1 >= i+jj:
                    b[i+jj] += 1
        # print(b)

    for l in range(n):
        a[l] = b[l] 
    
    b = [0] * n

print(a)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
num=0
ans=[0]*n
for i in range(1,19):
    if 2**i>n:
        num=i
        break
if k>num:
    ans=[n]*n
    print(*ans)
else:
    def abs_1(num1):
        return(abs(num1))
    for i in range(k):
        ans=[0]*n
        for j in range(n):
            for l in range(n):
                if abs_1(j-l)<=a[l]:
                    ans[j]+=1
        a=ans
    print(*a)

Submission status: Wrong Answer

Solution code:
import itertools

n,k= map(int, input().split())
a= list(map(int, input().split()))
if k>=20:
    ans=[n]*n
    print(*ans)
    exit()

ans=[0]*(n+1)
# ims
for i in range(k):
    ansx=[0]*(n+1)
    for j in range(n):
        if i==0:
            ansx[max(j - a[j], 0)] += 1
            ansx[min(n, j + a[j] + 1)] -= 1
        else:
            ansx[max(j - ans[j], 0)] += 1
            ansx[min(n, j + ans[j] + 1)] -= 1

    ansx = list(itertools.accumulate(ansx))
    ans=ansx


print(*ans[:n])

Submission status: Wrong Answer

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