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:
l = input().split()
N = int(l[0])
K = int(l[1])

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

be_left = [i for i in range(N)]
be_right = [i for i in range(N)]

dp = [[0 for i in range(N)] for j in range(K+1)]
dp[0] = A

for i in range(K):
    for j in range(N):
        dp[i+1][j] += dp[i][j]
        if dp[i][j]==0:
            dp[i+1][j]+=1
        
        left = j-dp[i][j]
        right = j+dp[i][j]
        if left<0:
            left = 0
        if right > N-1:
            right = N-1
        
        if left < be_left[j]:
            for k in range(left, be_left[j]):
                dp[i+1][k] += 1
        if right > be_right[j]:
            for k in range(be_right[j]+1, right+1):
                dp[i+1][k] += 1
        
        be_left[j] = left
        be_right[j] = right
           
        

print(*dp[K])
# print(*dp)

Submission status: Wrong Answer

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

check = []
for i in range(N):
    if a[i]:
        check.append([i,0,a[i]])
#print(check)
for i in range(k):
    if i!=0:
        a_next = a[:]
    else:
        a_next = [1 for _ in range(N)]
    change = set()
    for i,pre,now in check:
        for to in range(i+pre+1,i+now+1):
            if to >= N:break
            change.add(to)
            a_next[to] += 1
        for to in range(i-pre-1,i-now-1,-1):
            if to < 0:break
            change.add(to)
            a_next[to] += 1
        #print(a_next)
    check = []
    for to in change:
        check.append([to,a[to],a_next[to]])
    a = a_next
    if len(check) == 0:
        print(*a)
        exit()

print(*a)

Submission status: Wrong Answer

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

s = [0] * (n + 1)
for i in range(n):
    if i - a[i] * k >= 0:
        s[i - a[i] * k] += 1
    else:
        s[0] += 1
    if i + a[i] * k + 1 < n + 1:
        s[i + a[i] * k + 1] -= 1
    else:
        s[n] -= 1
            
s_ = [0] * (n + 1)
s_[0] = s[0]
    
for i in range(n):
    s_[i + 1] = s_[i] + s[i + 1]
        
print(*s_[:n])

Submission status: Wrong Answer

Solution code:
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    n, k = ZZ()
    A = ZZ() + [0]

    for _ in range(k):
        if A[0] >= n: break
        nA = [0] * (n+1)
        for i in range(n):
            nA[max(0, i-A[i])] += 1
            nA[min(n, i+1+A[i])] -= 1
        for i in range(1, n+1): nA[i] += nA[i-1]
        A = nA
    print(*A[:-1])

    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
n,k=map(int,input().split())
a=list(map(int,input().split()))
if False:
    print(*[n]*n)
else:
    for i in range(k):
        data=[0]*(n+1)
        for j in range(n):
          data[max(j-a[j-1]-1,0)]+=1
          data[min(j+a[j-1],n)]-=1
        r=[0]*n
        r[0]=data[0]  
        for i in range(1,n):
          r[i]=r[i-1]+data[i]
        if a==[n]*n:
            print(*[n]*n)
            sys.exit()
        a=r
    print(*a)

Submission status: Wrong Answer

Solution code:
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    n, k = ZZ()
    A = ZZ() + [0]

    for _ in range(k):
        if A[0] >= n: break
        nA = [0] * (n+1)
        for i in range(n):
            nA[max(0, i-A[i])] += 1
            nA[min(n-1, i+1+A[i])] -= 1
        for i in range(1, n+1): nA[i] += nA[i-1]
        A = nA
    print(*A[:-1])

    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans1=[]
ans2=[]
ans1+=a
ans2+=a
for i in range(min(k,32)):
  now=0
  ans2=[]
  ans2+=ans1
  kans=[0]*n
  for j in range(n):
    if j+ans2[j]+1<=n-1:
      kans[j+ans2[j]+1]-=1
    now+=1+kans[j]
    #基本kans[j]は0だが終点は-1
    ans1[j]=now
  now=0
  kans=[0]*n
  for j in range(1,n+1):
    if n-j-ans2[n-j]>=0:
      kans[n-j-ans2[n-j]-1]-=1
    now+=1+kans[n-j]
    #基本kans[j]は0だが終点は-1
    ans1[n-j]+=now-1
print(*ans1)

Submission status: Wrong Answer

Solution code:
# 幅優先探索（行きがけ）
import collections
import sys


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N, K = LI()
    aArray = LI()
    result = aArray
    arr = [0]*(N)
    print(aArray, len(arr))
    for i in range(K):
        if sum(aArray) < N**2:
            arr2 = arr
            aArray2 = aArray
            for j,a in enumerate(arr2):
                
                if a != aArray[j]:
                    sa = aArray[j] - a
                    for k in range(sa):
                        mai = j-k-1
                        pul = j+k+1
                        if mai > 0:
                            aArray[mai] += 1
                        if pul < N:
                            aArray[pul] += 1
                
            result[j] += aArray2[j]+1
            arr = aArray2
        else:
            for c in result:
                c += (K-i)*N
                print(c)
            break
    print(*result)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=0
aa=[]
for i in range(n):
    for j in range(n):
        if j-a[j]-0.5<=i and j+a[j]+0.5>=i:
            b+=1
        elif j+a[j]+0.5<i:
            break
    aa.append(b)
    b=0
    # print(i,*a)
print(*aa)

Submission status: Wrong Answer

Solution code:
import sys
n,k=map(int,input().split())
a=list(map(int,input().split()))
if False:
    print(*[n]*n)
else:
    for i in range(k):
        data=[0]*(n+1)
        for j in range(n):
          data[max(j-a[j-1]-1,0)]+=1
          data[min(j+a[j-1],n)]-=1
        r=[0]*n
        r[0]=data[0]  
        for i in range(1,n):
          r[i]=r[i-1]+data[i]
        if a==r:
            print(*[n]*n)
            sys.exit()
        a=r
    print(*a)

Submission status: Wrong Answer

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

for j in range(k):
    s = [0] * (n + 1)
    for i in range(n):
        if i - a[i] * k >= 0:
            s[i - a[i] * k] += 1
        else:
            s[0] += 1
        if i + a[i] * k + 1 < n + 1:
            s[i + a[i] * k + 1] -= 1
        else:
            s[n] -= 1
            
    s_ = [0] * (n + 1)
    s_[0] = s[0]
    
    for i in range(n):
        s_[i + 1] = s_[i] + s[i + 1]
        
    a = s_
    
print(*s_[:n])

Submission status: Wrong Answer

Solution code:
import sys

def main():
    input = sys.stdin.readline
    n, k = map(int, input().split())
    a = [int(x) for x in input().split()]
    key = 1
    nn = n
    while nn > 0:
        key += 1
        nn //= 2
    
    for _ in range(min([key*2, k])):
        b = [0]*n
        for i in range(n):
            l, r = max([i-a[i], 0]), min([i+a[i], n-1])
            b[l] += 1
            if r != n-1:
                b[r+1] -= 1
        for i in range(n):
            a[i] = 0
            a[i] += b[i]
            if i != 0:
                 a[i] += a[i-1]
    print(*a)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import deque

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

al = list(map(int, input().split()))
ade = deque(al)
a =  "".join([str(n) for n in al])

ans = 0

for _ in range(k):
    newa = 0
    for i in range(n):
        ai = ade.popleft()
        if i - ai >= 0:
            if i + ai <= n-1:
                newa += int("1"*(2*ai+1))*10**(n-(i+ai)-1)
            else:
                newa += int("1"*(2*ai+1-(i+ai-n)))
        elif i + ai <= n-1:
            newa += int("1"*(2*ai+1-(ai-i)))*10**(n-(i+ai)-1)
        else:
            newa += int("1"*n)
    ade = deque(map(int,list(str(newa))))

print(newa)

Submission status: Wrong Answer

Solution code:
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
import numpy as np
# sympy as syp(素因数分解とか)
Mod = 1000000007
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1] 
for i in range(2, 10**5 + 1):
    fact.append((fact[-1] * i) % Mod)
    inv.append((-inv[Mod % i] * (Mod // i)) % Mod)
    factinv.append((factinv[-1] * inv[-1]) % Mod)
    
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p
    
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    print("降参でーす！")
if __name__ == "__main__":
    main() #endline===============================================

Submission status: Wrong Answer

Solution code:
import numpy as np
n,k=map(int,input().split())
a=np.array(list(map(int,input().split())))
ans=a

if k>=n-1:
    print(*[n]*n)
    exit()

tmp=np.zeros(n,dtype=int)
for i in range(n):
    tmp[max(0,i-ans[i]) : min(n,i+ans[i]+1)]+=1
ans=tmp

k-=1
ans+=max(0,2*k-1)


print(*ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans1=[]
ans2=[]
ans1+=a
ans2+=a
for i in range(min(k,32)):
  now=0
  ans2=[]
  ans2+=ans1
  kans=[0]*n
  for j in range(n):
    if j+ans2[j]+1<=n-1:
      kans[j+ans2[j]+1]-=1
    now+=1+kans[j]
    #基本kans[j]は0だが終点は-1
    ans1[j]=now
  now=0
  kans=[0]*n
  for j in range(1,n+1):
    if n-j-ans2[n-j]>=0:
      kans[n-j-ans2[n-j]-1]-=1
    now+=1+kans[n-j]
    #基本kans[j]は0だが終点は-1
    ans1[n-j]+=now-1
  if i==min(k,32)-1 and (n-1)*n==sum(ans1):
    for i in range(n):
      ans1[i]+=1
print(*ans1)

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):
            if i > 1:
                print(' ', end='')
            print(N, end='')
        print()
        sys.exit()
    for i in range(1, N+1):
        if a[i - 1] > N:
            a[i - 1] = N
        A[i] = a[i - 1]
    for _ in range(K):
        count = [0] * (N + 1)
        left = []
        right = []
        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
            left.append(left_d)
            right.append(right_d)
        left.sort()
        right.sort()
        s = 0
        t = 0
        c = 0
        for i in range(1, N+1):
            if i == left[s]:
                s += 1
                c += 1
            if i == right[t]:
                t += 1
                c -= 1
            count[i] = c
        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 sys
N,K = map(int,input().split())
A = list(map(int,input().split()))
n = len(A)
B = A
fill = [0]*n
i_count = A #座標iを照らすライトの数
for z in range(K):
  for i in range(1,n+1):
    light = B[i-1]
    if B[i-1] != A[i-1]:
      for x in range(i-light,i+light+1):
        if x >= 1 and x <= n:
          i_count[x-1] += 1
          if i_count[x-1] == n:
            fill[x-1] = 1
  A = B
  B = i_count
  if sum(fill) == n:
    break
print(*A, end=' ')

Submission status: Wrong Answer

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

import math
    
for i in range(K):
  for j in range(N):
    for k in range(N):
      if j < k and  j > math.floor(k - A[k] -0.5):
        B[j] += 1
      elif j > k and  j < math.ceil(k + A[k] +0.5):
        B[j] += 1
      elif j == k:
        B[j] += 1
  A = B

print(B)

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()))
    zeros=[0 for i in range(n)]
    if max(a)==0:
        a=[1]*n
        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=min(j+1,n)
                #print(l,r)
                x[l]+=1
                if r!=n:
                #print(r)
                    x[r]+=-1
                #print(x)
            else:
                l=max(0,j-a[j])
                r=min(j+a[j]+1,n)
                #print(l,r)
                x[l]+=1
                if r!=n:
                    #print(r)
                    x[r]+=-1
                #print(x)
        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]
 
        #print(*ruiseki)
    print(*a)
if __name__=="__main__":
    main()

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):
        for j in range(max(i-A[i], 0), min(A[i]+i+1, N)):
            B[j] += 1
    A = B
print(A)

Submission status: Wrong Answer

Solution code:
import sys
N, K = map(int, input().split())
A = list(map(int, input().split()))
imos = [0]*(N+1)
for i, ai in enumerate(A):
    imos[max(0, i-ai-K)] += 1
    imos[min(N, i+ai+K+1)] -= 1
ans = [imos[0]]
for i in range(1, N):
    ans += [imos[i]+ans[i-1]]
print(' '.join(map(str, ans)))

Submission status: Wrong Answer

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

for i in range(k + 1):
    a.append([0] * n)
flag = 0

for i in range(k):
    if i == 0:
        for j in range(n):
            for l in range(-a[i][j], a[i][j] + 1):
                if 0 <= j + l < n:
                    a[i + 1][j + l] += 1
    else:
        cnt = 0
        for j in range(n):
            a[i + 1][j] += a[i][j]
            if a[i][j] == n:
                cnt += 1
        if cnt == n:
            flag = 1
            print(*a[i])
            break
        for j in range(n):
            if a[i][j] - a[i - 1][j] != 0:
                for l in range(1, a[i][j] - a[i - 1][j] + 1):
                    if 0 <= j - a[i - 1][j] - l:
                        a[i + 1][j - a[i - 1][j] - l] += 1
                    if j + a[i - 1][j] + l < n:
                        a[i + 1][j + a[i - 1][j] + l] += 1


if flag == 0:
    print(a[k])

Submission status: Wrong Answer

Solution code:
#C
import numpy as np
n,k=map(int,input().split())
a_list=np.array(list(map(int,input().split())))#電球の明るさ
d_list=np.array([0]*n)#照らされてる明るさ
s=0
g=0
#print(a_list)
#print(d_list)

#初期でどこがどれぐらい照らされてるか
def light(a_list,d_list):
    d_list=np.array([0]*n)
    for i in range(n):
        a=a_list[i]
        if i-a<0:
            s=0
        else:
            s=i-a
        if i+a+1>=n:
            g=n
        else:
            g=i+a+1
        d_list[s:g] += 1
    return a_list,d_list

z=light(a_list,d_list)
a_list=z[0]
d_list=z[1]
#print(a_list)
#print(d_list)

for _ in range(k):
    z=light(a_list,d_list)    
    a_list=z[0]
    d_list=z[1]
    a_list=d_list
print(a_list)
#print(d_list)

Submission status: Wrong Answer

Solution code:
import sys
n,k=map(int,input().split())
a=list(map(int,input().split()))
if n<=k:
    print(*[n]*n)
else:
    for i in range(k):
        data=[0]*(n+1)
        for j in range(n):
          data[max(j-a[j-1]-1,0)]+=1
          data[min(j+a[j-1],n)]-=1
        r=[0]*n
        r[0]=data[0]  
        for i in range(1,n):
          r[i]=r[i-1]+data[i]
        if a==r:
            print(*[n]*n)
            sys.exit()
        a=r
    print(*a)

Submission status: Wrong Answer

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

if k>=n-sum(a):
    a=[n]*n
    print(*a)
    exit()

class segtree:
    x_unit=0 # 要素として入れられる最大値
    def __init__(self,N):
        self.n=(1<<len(bin(N-1)[2:]))
        self.x=[self.x_unit]*(2*self.n)

    def build(self, seq):
        for i,j in enumerate(seq, start=self.n):  # n番目からseqをx配列に移していく
            self.x[i] = j
        for i in range(self.n-1, 0, -1):
            self.x[i] = 0
            # セグ木トーナメント表の左右を比較
            # 例えばn=8の時、seq[4]はx[12]に、seq[5]はx[13]に入っている
            # さらにx[14]とx[15]の間に来るのはx[7]、x[12]とx[13]の間に来るのはx[6]

    def fold(self,l,r): # 区間[l, r)値に+1 
        l+=self.n
        r+=self.n-1
        while l<r:
            if l%2==1: # lが奇数
                self.x[l]+=1
                l+=1 # 偶数に調節
            if r%2==0: # rが偶数
                self.x[r]+=1
                r-=1 # 開区間なので1個前は奇数番目の要素
            l //= 2
            r //= 2
        if l==r:
            self.x[l]+=1
        #print(self.x)
    def get(self,i): # seq[i]に対する値を取得 
        i+=self.n
        ret=self.x[i]
        while i>1:
            i //= 2
            ret+=self.x[i]
        return ret

for z in range(k):
    seq=[0]*n
    q=[(max(0, i-a[i]), min(n,i+a[i]+1)) for i in range(n)]
    seg=segtree(n)
    seg.build(seq)
    for i in range(n):
        l,r=q[i]
        seg.fold(l,r)
    ans=[]
    for i in range(n):
        ans.append(seg.get(i))
    a=ans+[]
    if all([i==n for i in a]):
        break
print(*a)

Submission status: Wrong Answer

Solution code:
import copy
N, K = map(int, input().split())

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

for k in range(K):
    next_array = [1] * N
    minus_array = [0] * N
    plus = 0
    for i in range(N):
        next_array[i] += plus
        plus += 1
        if i + A_array[i] < N:
            minus_array[(i + A_array[i])] += 1
        plus -= minus_array[i]

    minus_array = [0] * N
    plus = 0
    for i in range(N - 1, -1, -1):
        next_array[i] += plus
        plus += 1
        if i - A_array[i] >= 0:
            minus_array[(i - A_array[i])] += 1
        plus -= minus_array[i]
    A_array = copy.deepcopy(next_array)
    if A_array == [N] * N:
        break

print(A_array)

Submission status: Wrong Answer

Solution code:
import copy
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = [n for i in range(n)]
#最初に右側だけを考慮
right = [0 for i in range(n)]

for i in range(k):
    r_check = {}
    r_kinds = 0
    for i,j in enumerate(a):
        p = copy.deepcopy(r_kinds)
        if i in r_check:
            r_kinds -= r_check[i]
        num = 1 + p + k - 1
    #print(num,p,r_check,i)
        if num <= n:
            right[i] += num
        else:
            right[i] += n
        if j != 0:
            if not i + j in r_check:
                r_check[i + j] = 1
            else:
                r_check[i + j] += 1
            r_kinds += 1
    a = right
    #print(right)
#print(right)
#次に左側だけを考慮
left = [0 for i in range(n)]

b = a[::-1]
for cnt in range(k):
    l_check = {}
    l_kinds = 0
    for i,j in enumerate(b):
        p = copy.deepcopy(l_kinds)
        if i in l_check:
            l_kinds -= l_check[i]
        num = 1 + p + k - 1
            #print(num,p,r_check,i)
        if num <= n:
            left[i] += num
        else:
            left[i] += n
        if j != 0:
            if not i + j in l_check:
                l_check[i + j] = 1
            else:
                l_check[i + j] += 1
            l_kinds += 1
    b = left
left = left[::-1]
#print(left)
#最後にそれを足し算
for i in range(n):
    ans[i] = right[i]+left[i]
ans = list(map(lambda x:x-1,ans))
ans = list(map(str,ans))
print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]
if N%2 == 0:
    b = N//2
else:
    b = (N//2) +2
if N==1:
    print(1)
    exit()
if K >= 33:
    for i in range(N-1):
        print(N,end=" ")
    print(N)
    exit()
nextgen2 = [0]*N
for k in range(K):
    nextgen = nextgen2.copy()
    for i in range(N):
        # print("i=",i)
        a = A[i]
        start = i-a
        if i-a <0:
            start = 0
        end = i+a+1
        if i+a+1 <=N-1:
            nextgen[end] += -1
            end = N-1
        # print(start,end)
        nextgen[start] += 1
        # print(nextgen)
    dp = 0
    for i in range(N):
        dp += nextgen[i]
        A[i] = dp
s = ' '.join([str(i) for i in A])
print(s)

Submission status: Wrong Answer

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

    for i in range(len(A)):
        A[i] = d[i]

print(A)

Submission status: Wrong Answer

Solution code:
import numpy as np

# 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))
if K > N//2-1:
  print(" ".join([str(N)]*N))
  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:
import math
import sys

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

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()
  if A == ans:
    print(ans)
    sys.exit()

print(A[1:])

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans1=[]
ans2=[]
ans1+=a
ans2+=a
for i in range(min(k,32)):
  now=0
  ans2=[]
  ans2+=ans1
  kans=[0]*n
  for j in range(n):
    if j+ans2[j]+1<=n-1:
      kans[j+ans2[j]+1]-=1
    now+=1+kans[j]
    #基本kans[j]は0だが終点は-1
    ans1[j]=now
  now=0
  kans=[0]*n
  for j in range(1,n+1):
    if n-j-ans2[n-j]>=0:
      kans[n-j-ans2[n-j]-1]-=1
    now+=1+kans[n-j]
    #基本kans[j]は0だが終点は-1
    ans1[n-j]+=now-1
  if (n-1)*n==sum(ans1):
    for i in range(n):
      ans1[i]+=1
print(*ans1)

Submission status: Wrong Answer

Solution code:

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

b = [0]*n

for i in range(n):
  count = 0
  for l in range(0, i-k):
    if i - l + a[l] <= k:
      count += 1
  for m in range(max(0, i-k), min(n, i+k+1)):
    count += 1
  for r in range(i+k+1, n):
    if r-i-a[r] <= k:
      count += 1
  b[i] = count
       
print(" ".join(list(map(str, b))))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
*lumen, = list(map(int, input().split()))
lamps = [set() for i in range(n)]
num_of_lamps = [0] * n

for i in range(1, n+1):
    x_min = i - lumen[i-1]
    x_max = i + lumen[i-1]
    if x_min < 1:
        x_min = 1
    if x_max > n:
        x_max = n
    num_of_lamps[i-1] = x_max - x_min + 1

for i in range(k):
    for i in range(1, n+1):
        x_min = i - lumen[i-1]
        x_max = i + lumen[i-1]
        if x_min < 1:
            x_min = 1
        if x_max > n:
            x_max = n
        num_of_lamps[i-1] = x_max - x_min + 1

    lumen = num_of_lamps

lumen = ' '.join(list(map(str,lumen)))
print(lumen)

Submission status: Wrong Answer

Solution code:
import collections

n, K = map(int, input().split())
a = [int(i) for i in input().split()]

for k in range(K):
    change_list = []
    for i in range(n):
        if k > 0:
            a[i] = counter[i+1]
        change_list.extend([j for j in range(1,n+1) if i-a[i]+0.5 < j < i+a[i]+1.5])
    counter = collections.Counter(change_list)

ans_list = [str(c) for c in a]
ans=' '.join(ans_list)
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=0
aa=[]
for i in range(n):
    for j in range(n):
        if j-a[j]-0.5<=i and j+a[j]+0.5>=i:
            b+=1
    aa.append(b)
    b=0
    # print(i,*a)
print(*aa)

Submission status: Wrong Answer

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

ans = [0] * n
b = [0] * n

for _ in range(k):
    for idx_a, val in enumerate(a):
        for j in range(idx_a, idx_a + val + 1):
            if j <= n - 1:
                b[j] += 1
        for m in range(idx_a - 1, idx_a - val - 1, -1):
            if m >= 0:
                b[m] += 1
    a = b

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

Submission status: Wrong Answer

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

for _ in range(K):
	t = [0] * (N + 1)
	for i in range(1, N + 1):
		if A[i] == 0:
			continue
		H = int(min(i + A[i] + 1, N)) + 1
		L = int(max(1, i - A[i] - 1))
		for j in range(L, H):
			if i != j:
				t[j] += 1
	A = [x + y for (x, y) in zip(A, t)]

print(A[1:])

Submission status: Wrong Answer

Solution code:
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]
if N%2 == 0:
    b = N//2
else:
    b = (N//2) +2
if N==1:
    print(1)
    exit()
if K >= 35:
    for i in range(N-1):
        print(N,end=" ")
    print(N)
    exit()
nextgen2 = [0]*N
for k in range(K):
    nextgen = nextgen2.copy()
    for i in range(N):
        # print("i=",i)
        a = A[i]
        start = i-a
        if i-a <0:
            start = 0
        end = i+a+1
        if i+a+1 <=N-1:
            nextgen[end] += -1
            end = N-1
        # print(start,end)
        nextgen[start] += 1
        # print(nextgen)
    dp = 0
    for i in range(N):
        dp += nextgen[i]
        A[i] = dp
s = ' '.join([str(i) for i in A])
print(s)

Submission status: Wrong Answer

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

def ZeroOrMore(NUM):
    if NUM > 0:
        return NUM
    else:
        return 0

def change(changingList):
    ANSList = [0] * len(changingList)
    for i in range(len(changingList)):
        ANSList[i] = 0
        for j in range(len(changingList)):
            if changingList[j] > 0:
                if j-i > 0:
                    if i >= (j-changingList[j]-1):
                        ANSList[i] += 1
                else:
                    if i <= (j+changingList[j]+1):
                        ANSList[i] += 1
    return ANSList

for i in range(K):
    Mylist = change(Mylist)
print(Mylist)

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
A = list(map(int, input().split()))
temp = [0 for _n in range(N)]
for k in range(K):
  for n in range(N):
    for nn in range(N):
      #print(A[nn],abs(nn-n))
      if A[nn]==0:
        pass
      else:
        if (A[nn])>=(abs(nn-n)):
          temp[n] += 1
      #print(temp)
  A = temp
  temp = [0 for _n in range(N)]
print(*A)

Submission status: Wrong Answer

Solution code:
def addone(arr):
    for i in range(len(arr)):
        arr[i] = arr[i] + 1
    return arr 

def light(As,N):
    A0 = [0] * N
    for i in range(N):
        lp = As[i]
        lmin = max(0, i - lp)
        lmax = min(N - 1, i + lp)
        A0[lmin:lmax + 1] = addone(A0[lmin:lmax + 1])
    return A0

def main():
    """"ここに今までのコード"""
    N,K = map(int, input().split())
    As = list(map(int, input().split()))

    for i in range(K):
        As = light(As, N)

    print(*As,sep=" ")

Submission status: Wrong Answer

Solution code:
a=[input() for i in range(2)]

#print(a)

b=[int(i) for i in a[0].split()]
d=[int(i) for i in a[1].split()]

li=[0 for i in range(b[0])]

def ope(d,i):
	global list2
	lcl=i-d[i]
	if lcl<0:
		lcl=0

	ucl=i+d[i]+1
	if ucl>len(d):
		ucl=len(d)

	d2=li[lcl:ucl]

	list2=list(map(lambda d2:d2+1,d2))
	li[lcl:ucl]=list2

for i in range(b[1]):
	for i in range(b[0]):
		ope(d,i)

print(li)