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

Solution in C++ (GCC 9.2.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>

#define int long long
#define ld long double
#define db double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define RAND mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define debx cout << " X " << endl;
#define deby cout << " Y " << endl;
#define debz cout << " Z " << endl;
#define deb(x) cout << '>' << #x << ':' << x << endl;

const long double PI = 3.14159265358979323846264338;
const long long INF = 1000000000000000000;
const long long INF1 = 1000000000;
const long long MOD = 1000000007;
// const long long MOD = 998244353;

using namespace __gnu_pbds; 
using namespace std;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update> ; 
/*  
    find_by_order() - Returns an iterator to the k-th largest element (counting from zero) 
    order_of_key()  - The number of items in a set that are strictly smaller than our item 
    Rest same as set
*/
 
int mpow(int a, int b){
    a %= MOD;
    if(!b)
        return 1;
    int temp = mpow(a, b/2);
    temp = (temp*temp) % MOD;
    if(b%2)
        return (a * temp) % MOD;
    return temp;
}
int _pow(int a, int b){
    if(!b)
        return 1;
    int temp = _pow(a, b/2);
    temp = (temp * temp);
    if(b%2)
        return (a * temp);
    return temp;
}
int mod_in(int n){
    return mpow(n, MOD-2);
}
int cl(int a, int b){
    if(a%b)
        return 1 + a/b;
    return a/b;
}

class SegTree{
    private:
        int *st = new int[10000000];
        int *lazy = new int[10000000];
        int n = 0;
    public:
        SegTree(int x){
            n = x;
            for(int i=0 ; i<4*x ; i++)
                st[i] = lazy[i] = 0;    
        }
        
        void update(int lo, int hi, int val){
            up(1, 1, n, lo, hi, val);
        }

        int query(int lo, int hi){
            return q(1, 1, n, lo, hi);
        }

        void up(int node, int l, int r, int lo, int hi, int val){
            if(lazy[node]){
                st[node] += lazy[node] * (r-l+1);
                if(r!=l){
                    lazy[2*node] += lazy[node];
                    lazy[2*node+1] += lazy[node];
                }
                lazy[node] = 0;
            }
            if(l>r || l>hi || lo>r)
                return;
            if(l>=lo && r<=hi){
                st[node] += (r-l+1) * val;
                if(r!=l){
                    lazy[2*node] += val;
                    lazy[2*node+1] += val;
                }
                return;
            }
            int mid = (l+r) / 2;
            up(2*node, l, mid, lo, hi, val);    
            up(2*node+1, mid+1, r, lo, hi, val);
            st[node] = st[2*node] + st[2*node+1];
            return;
        }
 
        int q(int node, int l, int r, int lo, int hi){
            if(lazy[node]){
                st[node] += lazy[node] * (r-l+1);
                if(r!=l){
                    lazy[2*node] += lazy[node];
                    lazy[2*node+1] += lazy[node];
                }
                lazy[node] = 0;
            }
            if(l>r || l>hi || lo>r)
                return 0;
            if(l>=lo && r<=hi){
                return st[node] ;
            }
            int mid = (l+r) / 2;
            int q1 = q(2*node, l, mid, lo, hi);    
            int q2 = q(2*node+1, mid+1, r, lo, hi);
            return q1 + q2;
        }
  
        void clear(){
            delete st;
            delete lazy;
        }
};

int32_t main(){
    fastio;
    int n, k;
    cin >> n >> k;
    if(k >= (int) log(n) + 18){
        for(int i=0 ; i<n ; i++)
            cout << n << " ";
        exit(0);
    }
    int a[n+5];
    for(int i=1 ; i<=n ; i++){
        cin >> a[i];
    }
    SegTree st = SegTree(n);
    int Z = min(k, (int) log(n) + 13);
    for(int j=0 ; j<Z ; j++){
        for(int i=1 ; i<=n ; i++){
            int l = max(1ll, i - a[i]);
            int r = min(n, i + a[i]);
            st.update(l, r, 1);
        }
        for(int i=1 ; i<=n ; i++){
            a[i] = st.query(i,i) ;
            st.update(i, i, -a[i]);
        }
    }
    for(int i=1 ; i<=n ; i++)
        cout << a[i] << " ";
}