Language: C++

#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long

const int MAXSSTN = 200010;
class StarrySkyTree{
public:
  int size=0;
  int depth=0; // the depth of the tree
  int best=0;  // the index of maximum element
  int start=0; // the initial index of inputs
  long long dat_add[3 * MAXSSTN];
  long long dat[3 * MAXSSTN];
  StarrySkyTree(int n){
    size=n;
    while((1<<depth)<n)depth++;
    start=(1<<depth)-1;
    for(int i=start;i<(1<<(depth+1));i++){
      dat[i]=-1e15;
    }
  }
  StarrySkyTree(int n,long long* v){
    size=n;
    while((1<<depth)<n)depth++;
    start=(1<<depth)-1;
    for(int i=start;i<(1<<(depth+1));i++){
      if(i<start+n)
	dat[i]=v[i-start];
      else
	dat[i]=-1e15;
    }
    for(int i=start;i<start+n;i++){
      int tmp=i;
      while(par(tmp)!=-1){
	dat[par(tmp)]=max(dat[tmp],dat[(tmp+1)/2*4-1-tmp]);
	tmp=par(tmp);
      }
    }
    int i=0;
    while(i<start)i=(dat[i]==dat[2*i+1])?2*i+1:2*i+2;
    best=i-start;
  }
  long long max_element(int a, int b){ return max_element(a, b, 0, 0, (1<<depth)); }
  void add(int s, int t, long long x){ add(s, t, 0, 0, (1<<depth), x); }
  void add(int i, long long x){ add(i, i + 1, 0, 0, (1<<depth), x); }

  int par(int i){
    if(i==0)
      return -1;
    return (i-1)/2;
  }

  void clear(){
    
    REP(i,3*MAXSSTN){
      dat_add[i]=0;
      dat[i] = 0;
    }
    for(int i=start;i<(1<<(depth+1));i++){
      dat[i]=-1e15;
    }
  }

  void update(int d,long long x){
    int i=d+start;
    dat[i]=x;
    while(par(i)!=-1){
      dat[par(i)]=max(dat[i]+dat_add[i],dat[(i+1)/2*4-1-i]+dat_add[(i+1)/2*4-1-i]);
      i=par(i);
    }
    i=0;
    while(i<start){
      i=(dat[i]==dat[2*i+1])?2*i+1:2*i+2;
    }
    best=i-start;
  }
  void dump(){
    cerr<<"SegTree:"<<endl;
    for(int i=0;i<depth+1;i++){
      for(int j=0;j<(1<<i);j++)
	cerr<<dat[j+(1<<i)-1]<<" ";
      cerr<<endl;
    }
    cerr<<endl;
    cerr<<"SegTree lazy addition:"<<endl;
    for(int i=0;i<depth+1;i++){
      for(int j=0;j<(1<<i);j++)
	cerr<<dat_add[j+(1<<i)-1]<<" ";
      cerr<<endl;
    }
    cerr<<endl;
  }
private:
  long long max_element(int a, int b, int k, int l, int r){
    if(b <= l || r <= a) return -1e15;
    if(a <= l && r <= b) return dat[k] + dat_add[k];

    long long vl = max_element(a, b, k * 2+1, l, (l + r) / 2);
    long long vr = max_element(a, b, k * 2+2, (l + r) / 2, r);
    return max(vl, vr) + dat_add[k];
  }
  void add(int a, int b, int k, int l, int r, long long x){
    if(b <= l || r <= a) return;
    if(a <= l && r <= b){
      dat_add[k] += x;
    }else{
      add(a, b, k * 2+1, l, (l + r) / 2, x);
      add(a, b, k * 2+2, (l + r) / 2, r, x);
      dat[k] = max(dat[k * 2+1] + dat_add[k * 2+1], dat[k * 2 + 2] + dat_add[k * 2 + 2]);
    }
  }
};

int n,k;
int a[200000];
bool ignore[200000];
LL ignorecnt = 0;

int main(){
  cin>>n>>k;
  REP(i,n){cin>>a[i];
  ignore[i]=false;}
  if(k >= 41){
    REP(i,n)cout<<n<<" ";
    cout<<endl;
    return 0;
  }

  StarrySkyTree sst(n);
  REP(i,k){
    REP(j,n)sst.update(j,ignorecnt);
    REP(j,n){
      if(!ignore[j])
        sst.add(max(0,j-a[j]),min(n-1,j+a[j])+1,1);
    }
    REP(j,n){
      if(a[j] != n)
        a[j]=sst.max_element(j,j+1);
      if(!ignore[j] && max(0,j-a[j])==0 && min(n-1,j+a[j])+1 == n){
        ignore[j] = true;
        ignorecnt++;
      }
    }
    sst.clear();
  }

  REP(i,n)cout<<a[i]<<" ";
  cout<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:126:3: error: reference to 'ignore' is ambiguous
  126 |   ignore[i]=false;}
      |   ^~~~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/string:68,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/tuple:2855:47: note: candidates are: 'constexpr const std::_Swallow_assign std::ignore'
 2855 |   _GLIBCXX17_INLINE constexpr _Swallow_assign ignore{};
      |                                               ^~~~~~
a.cc:120:6: note:                 'bool ignore [200000]'
  120 | bool ignore[200000];
      |      ^~~~~~
a.cc:137:11: error: reference to 'ignore' is ambiguous
  137 |       if(!ignore[j])
      |           ^~~~~~
/usr/include/c++/14/tuple:2855:47: note: candidates are: 'constexpr const std::_Swallow_assign std::ignore'
 2855 |   _GLIBCXX17_INLINE constexpr _Swallow_assign ignore{};
      |                                               ^~~~~~
a.cc:120:6: note:                 'bool ignore [200000]'
  120 | bool ignore[200000];
      |      ^~~~~~
a.cc:143:11: error: reference to 'ignore' is ambiguous
  143 |       if(!ignore[j] && max(0,j-a[j])==0 && min(n-1,j+a[j])+1 == n){
      |           ^~~~~~
/usr/include/c++/14/tuple:2855:47: note: candidates are: 'constexpr const std::_Swallow_assign std::ignore'
 2855 |   _GLIBCXX17_INLINE constexpr _Swallow_assign ignore{};
      |                                               ^~~~~~
a.cc:120:6: note:                 'bool ignore [200000]'
  120 | bool ignore[200000];
      |      ^~~~~~
a.cc:144:9: error: reference to 'ignore' is ambiguous
  144 |         ignore[j] = true;
      |         ^~~~~~
/usr/include/c++/14/tuple:2855:47: note: candidates are: 'constexpr const std::_Swallow_assign std::ignore'
 2855 |   _GLIBCXX17_INLINE constexpr _Swallow_assign ignore{};
      |                                               ^~~~~~
a.cc:120:6: note:                 'bool ignore [200000]'
  120 | bool ignore[200000];
      |      ^~~~~~