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:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, K = map(int, input().split())
# 文字列の入力
#s = input()
#開業されたN個要素を受け付ける
input_list = list(map(int, input().split()))

if not (input_list == [0 for i in range(N)]):
    for i in range(K):
        if input_list == [N for i in range(N)]:
            break

        tmp_list = [1 for i in range(N)]
        for j in range(N):
            for l in range(input_list[j]):
                if 0 <= j-l-1:
                    tmp_list[j-l-1] = tmp_list[j-l-1]+1
                if j+l+1 <= N-1:
                    tmp_list[j+l+1] = tmp_list[j+l+1]+1
            #print(tmp_list)

        input_list = tmp_list

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

Submission status: Wrong Answer

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

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:
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())
n,k=mi()
a=li()
for i in range(k):
    tmp=[0]*n
    for j in range(n):
        x1=max(0,j-a[j])
        x2=min(n+1,j+a[j])
        tmp[x1]+=1
        if(x2<n-1):
            tmp[x2+1]-=1
       
    a[0]=tmp[0]
    for j in range(1,n):
        tmp[j]+=tmp[j-1]
        a[j]=tmp[j]
    if(min(a)>=n):
        print([n]*n)
        exit(0)
print(*a)

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

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

print(' '.join(list(map(str, 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(op, i):
  global A, B, N
  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
  if op == 0:
    for j in range(left, right+1):
      B[j] -= 1
  else:
    for j in range(left, right+1):
      B[j] += 1


for i in range(1, N+1):
  operation(1, i)

#print(A)
#print(B)

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

print(A[1:])

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) + 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(KL):
        for i in range(N):
            a[i] = raq.get(i)
        for i in range(N):
            raq.add(i, i+1, -a[i])
            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
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) <= 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()))
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:
N,K= map(int, input().split())
A_list = list(map(int, input().split()))

import math
import numpy as np


for i in range(K):
  print(i)
  count_list = np.array([0] * N)
  #何個光ってるか
  for j in range(N):
    count_list_sub = np.array([0] * N)
    first = math.floor(j+1 - A_list[j] - 0.5)+1
    last = math.floor(j+1 + A_list[j] + 0.5)
    if(first<1):
      first = 1
    if(last<1):
      last = 1
    if(first>N):
      first = N
    if(last>N):
      last = N
    count_list_sub[first-1:last]=[1]*((last)-(first-1))
    count_list = count_list_sub + count_list
  A_list = count_list
  
A_list=[str(a) for a in A_list]
A_list=' '.join(A_list)
print(A_list)

Submission status: Wrong Answer

Solution code:
import math
from sys import stdin,stdout
#% 998244353
from heapq import heapify,heappop,heappush
import collections

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


for i in range(4):
    #nw=[0]*n
    pr=[0]*n
    for x,d in enumerate(a):
        if d==0:
            pr[x]+=1
            if x!=n-1:
                pr[x+1]-=1
            continue
        l=math.floor(x-d)
        r=math.floor(x+d)
        l=max(0,l)
        r=min(n-1,r)
        pr[l]+=1
        if r!=n-1:
            pr[r+1]-=1
    
    for m in range(1,n):
        pr[m]+=pr[m-1]
    
    a[:]=pr


        

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

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

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

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

Submission status: Wrong Answer

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

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

for time in range(K):
  if isSatisfied(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(0, N):
        NEW_A[i+j] += 1

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

print(' '.join(strA))

Submission status: Wrong Answer

Solution code:
import sys
def main(N, K, A):
    for k in range(min(38, K)):
        C = [0] * (N + 1)
        for i in range(N):
            a = A[i]
            C[max(0, i - a)] += 1
            C[min(N, i + a + 1)] -= 1
        A[0] = C[0]
        for i in range(1, N):
            A[i] = A[i - 1] + C[i]
    return A

if __name__ == '__main__':
    input = sys.stdin.readline
    N, K = map(int, input().split())
    *A, = map(int, input().split())
    print(*main(N, K, A))

Submission status: Wrong Answer

Solution code:
import math
import copy

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

def operation(op, i):
  global A, B, N
  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
  if op == 0:
    for j in range(left, right+1):
      B[j] -= 1
  else:
    for j in range(left, right+1):
      B[j] += 1


for i in range(1, N+1):
  operation(1, i)

#print(A)
#print(B)

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

print(A[1:])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
from sys import stdin,stdout
#% 998244353
from heapq import heapify,heappop,heappush
import collections

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


for i in range(2):
    #nw=[0]*n
    pr=[0]*n
    for x,d in enumerate(a):
        if d==0:
            pr[x]+=1
            if x!=n-1:
                pr[x+1]-=1
            continue
        l=math.floor(x-d)
        r=math.floor(x+d)
        l=max(0,l)
        r=min(n-1,r)
        pr[l]+=1
        if r!=n-1:
            pr[r+1]-=1
    
    for m in range(1,n):
        pr[m]+=pr[m-1]
    
    a[:]=pr


        

for i in a:
    print(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 max(0, j - tmp) == min(N + 1, j + tmp):
            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 copy
import math

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

if k>=math.sqrt(2*n)+1:
    tmp = [len(a) for i in range(len(a))]
else:
    for i in range(k):
        tmp=[1 for j in range(len(a))]
        for num, i in enumerate(a):
            if i > max(len(a)-num,num):
                tmp = copy.copy([n+1 for n in tmp])
            else:
                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:
n, k = map(int, input().split())

if k >= n:
  for i in range(n):
    print(n, end=" ")

Submission status: Wrong Answer

Solution code:
import math
from sys import stdin,stdout
#% 998244353
from heapq import heapify,heappop,heappush
import collections

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



pr=[0]*n
for x,d in enumerate(a):
    if d==0:
        pr[x]+=1
        if x!=n-1:
            pr[x+1]-=1
        continue
    l=math.floor(x-d)
    r=math.floor(x+d)
    l=max(0,l)
    r=min(n-1,r)
    pr[l]+=1
    if r!=n-1:
        pr[r+1]-=1

for m in range(1,n):
    pr[m]+=pr[m-1]

a[:]=pr


        

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

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):
    if K > 2 * math.log2(N):
        print(' '.join([str(N)] * N))
        return
    raq = RAQ.from_array(A)
    a = [0 for i in range(N)]
    for k in range(K):
        for i in range(N):
            a[i] = raq.get(i)
        for i in range(N):
            raq.add(i, i+1, -a[i])
            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 = map(int,input().split())
ls = list(map(int,input().split()))

def f(x):
    if x == 0:
        return ls
    else:
        lsa = [0 for i in range(n)]
        lsb = f(x-1)
        for j in range(n):
            if lsb[j] == 0:
                lsa[j] += 1
            else:
                if lsb[j] - j - 1 < 0:
                    if j + lsb[j] - n < 0:
                        for l in range(j -lsb[j], j + lsb[j] + 1):
                            lsa[l] += 1
                    else:
                        for l in range(j - lsb[j], n ):
                            lsa[l] += 1
                else:
                    if j + lsb[j] - n < 0:
                        for l in range(j + lsb[j] + 1):
                            lsa[l] += 1
                    else:
                        for l in range(n):
                            lsa[l] += 1
        return lsa

print(f(k))

Submission status: Wrong Answer

Solution code:
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): #これでA[i]ごとにみる
        for j in range(N):#影響を与えるBを+1
             B[j] = B[j]+1 if i-A[i]<=j and j<=i+A[i] else B[j]
    A = B
print(B)

Submission status: Wrong Answer

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

if k >= n:
  for i in range(n):
    print(n, end="")

Submission status: Wrong Answer

Solution code:
import itertools
N,K = map(int,input().split())
A = list(map(int,input().split()))
if K >= 15:
    print(*[N]*N)
    exit()
for i in range(K):
    newA = [0]*N
    for j in range(N):
        newA[max(0,j-A[j])] += 1
        if j+A[j]+1 < N:
            newA[min(N-1,j+A[j]+1)] -= 1
    A = list(itertools.accumulate(newA))
    if A == [N]*N:
        break
print(*A)

Submission status: Wrong Answer

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

for i in range(k):
    lit = [0 for _ in range(n)]
    for _ in range(0, n):
        mx = max(0,_ - lst[_])
        mn = min(n, _ + lst[_] +1)
        lit[mx:mn] = map(lambda x:x+1, lit[mx:mn])
    lst = lit
    if set(lst) == {n}:
        break
print(lst)

Submission status: Wrong Answer

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

def terasu(a):
    new_a = [1]*n
    for j,l in enumerate(a):
        if l > 0:
            for i in range(-l,l+1):
                if j+i >= 0 and j+i<n:
                    new_a[j+i]+=1
    return(new_a)

for x in range(k):
    a = terasu(a)

print(" ".join([str(x) for x in a]))

Submission status: Wrong Answer

Solution code:
N , K = map(int , input().split())
A = list(map(int , input().split()))
if K >= (N-1):
    S = [N]*(N)
    print(*S)

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_update = True

    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
        if a[i] != n:
            is_update = False

    return is_update


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

for i in range(k):
    ret = update(a, n)
    if 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()))

if k >= n:
    for i in range(n-1):
        print(n, end=" ")
    print(n)
    exit()

tmp = [1]*n
li = []
for i in range(k):
    li.append(tmp.copy())
for i, d in enumerate(a):
    if d == 0:
        continue
    for j in range(-d, d+1):
        if j == 0:
            continue
        if i+j >= 0:
            try:
                li[0][i+j] += 1
                # print(i, j)
            except:
                pass
for h in range(k):
    print(li[h])
    for i, d in enumerate(li[h]):
        if d == 0:
            continue
        for j in range(-d, d+1):
            if j == 0:
                continue
            if i+j >= 0:
                try:
                    li[h+1][i+j] += 1
                    # print(i, j)
                except:
                    pass

print(li)
for i in range(n-1):
    print(li[-1][i], end=" ")
print(li[-1][-1])

Submission status: Wrong Answer

Solution code:
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))
for k in range(k):
    d = []
    for i in range(n):
         d.extend(list(range(int(i - a[i]), int(i + a[i] + 1))))
    print(d)
    c = []
    c = Counter(d)
    print(c)
    for j in c.keys():
        if j >= 0 and j < len(a):
            a[j] = c[j]

L=[str(t) for t in a]
L=" ".join(L)
print(L)

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:
    A = map(str, A)
    print(" ".join(A))
    sys.exit()

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 max(0, j - tmp) == min(N + 1, j + tmp):
            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 numpy as np

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

#Sn = np.array([[0 for i in range(N)] for i in range(N)])
#for i in range(N):
#    Sn[i][max(0,i - An[i]): min(i + An[i] + 1, N)] = 1
#print(Sn)

Hn = np.array([ i + An[i] for i in range(N)])
Ln = np.array([ i - An[i] for i in range(N)])

for i in range(K):
    pre_An = np.array(An)
    An = [sum((Ln<=i)&(i<=Hn)) for i in range(N)]
    diff = An-pre_An
    Hn += diff
    Ln -= diff
    
print(An)

Submission status: Wrong Answer

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

akarusa = np.array(A)


for k in range(K):
    tmp_akarusa = np.zeros(N, dtype = int)
    for i in range(1,N+1):
        for j in range(1, N+1):
            if abs(j - i) <= akarusa[j-1] + 0.5:
                tmp_akarusa[i-1] = tmp_akarusa[i-1] + 1
    akarusa = tmp_akarusa

print(akarusa)

Submission status: Wrong Answer

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

for i in range(k):
    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:
import numpy as np

N, K = map(int, input().split(' '))
A = tuple(map(int, input().split(' ')))
indexes = np.arange(0, N)

dp = np.zeros(shape=N + 1, dtype=np.int64)

if K >= 33 and False:
    A = [N for _ in range(N)]
else:
    for k in range(min(33, K)):
        np.add.at(dp, np.maximum(0, indexes - A), 1)
        np.add.at(dp, np.minimum(N, indexes + A + 1), -1)
        A = dp.cumsum()[:-1]
        if np.all(A == N):
            break
        dp *= 0

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

Submission status: Wrong Answer

Solution code:
def main():
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    zeros=[0 for i in range(n)]
    if max(a)==0:
        print(*a)
        exit()
    if min(a)==n:
        print(*a)
        exit()
    for i in range(k):
        x=zeros.copy()
        for j in range(n):
            if a[j]==0:
                l=j
                r=j+1
            else:
                l=max(0,j-a[j])
                r=j+a[j]+1
        #    print(l,r)
            x[l]+=1
            if r+1<=n:
                x[r]+=-1
        ruiseki=[0]*n
        ruiseki[0]=x[0]
        a[0]=ruiseki[0]
        mina=a[0]
        for i in range(1,n):
            ruiseki[i]=ruiseki[i-1]+x[i]
            a[i]=ruiseki[i]
            if a[i]<mina:
                mina=a[i]
        if mina==n:
            print(*a)
            exit()
    #  print(*ruiseki)
    print(*a)
if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

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

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

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")
import time
t1=time.time()
n,k=LI()
a=LI()

a=[n]*n

print(*a)

Submission status: Wrong Answer

Solution code:
import itertools

N, K = map(int,input().split())
A = list(map(int,input().split()))
B = [0] * (N+1)
chk = [N] *N
for k in range(K):
    if A == chk:
        break
    for i in range(N):
        if A[i] == 0:
            B[i] += 1
            B[i+1] -= 1
            continue
        l = i - A[i]
        r = i + A[i]
        if l <= 0:
            B[0] += 1
        else:
            B[l] += 1
        if r >= N-1:
            B[N] -= 1
        else:
            B[r+1] -= 1        
    A = list(itertools.accumulate(B))[:-1]
    B = [0] * (N+1)
print(A)
#print("B = " ,B)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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



for _ in range(K):
    count_list = []
    for x in range(len(given_list)):
        count = 0
        trg_place = x

        for l in range(len(given_list)):
            rela_place = l

            if trg_place == rela_place:
                count += 1
            elif abs(trg_place - rela_place) <= 0.5 + given_list[l]:
                count += 1
            else:
                count += 0
        count_list.append(count)
    
    given_list = count_list

print(given_list)

Submission status: Wrong Answer

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

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

print(A)

Submission status: Wrong Answer

Solution code:
import itertools
N,K = map(int,input().split())
A = list(map(int,input().split()))
if K >= 10:
    print(*[N]*N)
    exit()
for i in range(K):
    newA = [0]*N
    for j in range(N):
        newA[max(0,j-A[j])] += 1
        if j+A[j]+1 < N:
            newA[min(N-1,j+A[j]+1)] -= 1
    A = list(itertools.accumulate(newA))
    if A == [N]*N:
        break
print(*A)