Language: C++


#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;
 
signed main(){
	int N,K;
	cin >> N >> K;
	vector<int>a(N);
	REP(i,N){
		cin >> a[i];
	}
	int LOG2 = log2(200010);
	REP(i,min(K,1000)){
		vector<int>b(N + 1);
		REP(j,N){
			int l = max(0ll,j - a[j]);
			int r = min(N - 1,j + a[j]);
			b[r + 1] += -1;
			b[l] += 1;
		}
		REP(j,N){
			b[j + 1] += b[j];
		}
		REP(j,N)a[j] = b[j];
	}
	REP(i,a.size())cout << a[i] << " \n"[i+1 == a.size()];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:18: error: no matching function for call to 'min(long long int&, int)'
   25 |         REP(i,min(K,1000)){
      |               ~~~^~~~~~~~
a.cc:5:44: note: in definition of macro 'REP'
    5 | #define REP(i, n) for (int i = 0; i < (int)n; ++i)
      |                                            ^
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:25:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   25 |         REP(i,min(K,1000)){
      |               ~~~^~~~~~~~
a.cc:5:44: note: in definition of macro 'REP'
    5 | #define REP(i, n) for (int i = 0; i < (int)n; ++i)
      |                                            ^
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:25:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   25 |         REP(i,min(K,1000)){
      |               ~~~^~~~~~~~
a.cc:5:44: note: in definition of macro 'REP'
    5 | #define REP(i, n) for (int i = 0; i < (int)n; ++i)
      |                                            ^