Language: C++

#include<cassert>
#include<vector>
#include<cstdint>
#include<cstddef>
#include<memory>
#include<utility>

template<typename T, typename U>
class PersistentLazySegmentTree{
public:
	using value_type = T;
	using operator_type = U;
	using size_type = std::size_t;




private:
	struct node_t{
		using ptr_type = std::shared_ptr < const node_t >;
		ptr_type l, r;
		value_type value;
		operator_type lazy;

		node_t(ptr_type &&x, ptr_type &&y, value_type &&z, operator_type&&w) :l(std::move(x)), r(std::move(y)), value(std::move(z)), lazy(std::move(w)){}
		value_type reflect()const{
			return value*lazy;
		}
		static ptr_type set(ptr_type &&x, ptr_type &&y){
			value_type &&temp = x->reflect() + y->reflect();
			return std::make_shared<const node_t>(std::move(x), std::move(y), std::move(temp), operator_type());
		}
		ptr_type assign(const operator_type &data)const{
			return std::make_shared<const node_t>(l, r, value, lazy + data);
		}
		ptr_type update(const size_type first, const size_type last, const size_type left, const size_type right, const operator_type &acc, const operator_type &data)const{
			if (right <= first || last <= left)return assign(acc);
			if (first <= left&&right <= last)return assign(acc + lazy);
			return set(l->update(first, last, left, (left + right) >> 1, lazy + acc, data),
				r->update(first, last, (left + right) >> 1, right, lazy + acc, data));
		}
		value_type range(const size_type first, const size_type last, const size_type left, const size_type right, const operator_type &acc)const{
			if (right <= first || last <= left)return value_type();
			if (first <= left&&right <= last)return reflect()*acc;
			return l->range(first, last, left, (left + right) >> 1, lazy + acc) +
				r->range(first, last, (left + right) >> 1, right, lazy + acc);
		}
	};
	using ptr_type = typename node_t::ptr_type;

	ptr_type root;
	const size_type height;
	static size_type getheight(const size_type size){
		size_type ret = 1;
		while ((static_cast<size_type>(1) << ret) < size)++ret;
		return ret;
	}
	explicit PersistentLazySegmentTree(ptr_type&& root_,const size_type height_) :root(std::move(root)),height(height_){}
public:
	explicit PersistentLazySegmentTree(const size_type size) :height(getheight(size)){}
	PersistentLazySegmentTree &operator=(const PersistentLazySegmentTree &x){
		assert(height == x.height);
		root = x.root;
		return *this;
	}
	PersistentLazySegmentTree &operator=(PersistentLazySegmentTree &&x){
		assert(height == x.height);
		root = std::move(x.root);
		return *this;
	}
	PersistentLazySegmentTree update(const size_type first, const size_type last, const operator_type &data)const{
		return PersistentLazySegmentTree(root->update(first, last, 0, static_cast<size_type>(1) << height, operator_type(), data),height);
	}
	value_type range(const size_type first, const size_type last)const{
		return root->range(first, last, 0, static_cast<size_type>(1) << height, operator_type());
	}
};


#include<algorithm>
#include<iostream>
const int INF = 2147483647;

struct Ass{
	int a;
	bool f;
	Ass():f(1){}
	Ass(int x) :a(x), f(0){}
	Ass operator+(const Ass &x)const{
		if (x.f)return *this;
		return x;
	}
};
struct Mini{
	int a;
	Mini(int x = INF) :a(x){}
	Mini operator+(const Mini &x)const{
		return Mini(std::min(a, x.a));
	}
	Mini operator*(const Ass &x)const{
		if (x.f)return *this;
		return Mini(x.a);
	}
};

int main(){
	int n, q;
	std::cin >> n >> q;
	PersistentLazySegmentTree<Mini, Ass> T(n);
	int c,s, t, x;
	while (q--){
		std::cin >> c >> s >> t;
		if (c){
			std::cout << T.range(s, t + 1).a << std::endl;
		}
		else{
			std::cin >> x;
			T = T.update(s, t + 1, Ass(x));
		}
	}
	return 0;
}


Compiler output:
In file included from /usr/include/c++/14/vector:64,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_construct.h: In instantiation of 'void std::_Construct(_Tp*, _Args&& ...) [with _Tp = const PersistentLazySegmentTree<Mini, Ass>::node_t; _Args = {const shared_ptr<const PersistentLazySegmentTree<Mini, Ass>::node_t>&, const shared_ptr<const PersistentLazySegmentTree<Mini, Ass>::node_t>&, const Mini&, Ass}]':
/usr/include/c++/14/bits/alloc_traits.h:706:19:   required from 'static void std::allocator_traits<std::allocator<void> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = const PersistentLazySegmentTree<Mini, Ass>::node_t; _Args = {const std::shared_ptr<const PersistentLazySegmentTree<Mini, Ass>::node_t>&, const std::shared_ptr<const PersistentLazySegmentTree<Mini, Ass>::node_t>&, const Mini&, Ass}; allocator_type = std::allocator<void>]'
  706 |         { std::_Construct(__p, std::forward<_Args>(__args)...); }
      |           ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/shared_ptr_base.h:607:39:   required from 'std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_Sp_counted_ptr_inplace(_Alloc, _Args&& ...) [with _Args = {const std::shared_ptr<const PersistentLazySegmentTree<Mini, Ass>::node_t>&, const std::shared_ptr<const PersistentLazySegmentTree<Mini, Ass>::node_t>&, const Mini&, Ass}; _Tp = const PersistentLazySegmentTree<Mini, Ass>::node_t; _Alloc = std::allocator<void>; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]'
  607 |           allocator_traits<_Alloc>::construct(__a, _M_ptr(),
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
  608 |               std::forward<_Args>(__args)...); // might throw
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
/usr/include/c++/14/bits/shared_ptr_base.h:969:16:   required from 'std::__shared_count<_Lp>::__shared_count(_Tp*&, std::_Sp_alloc_shared_tag<_Alloc>, _Args&& ...) [with _Tp = const PersistentLazySegmentTree<Mini, Ass>::node_t; _Alloc = std::allocator<void>; _Args = {const std::shared_ptr<const PersistentLazySegmentTree<Mini, Ass>::node_t>&, const std::shared_ptr<const PersistentLazySegmentTree<Mini, Ass>::node_t>&, const Mini&, Ass}; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]'
  969 |           auto __pi = ::new (__mem)
      |                       ^~~~~~~~~~~~~
  970 |             _Sp_cp_type(__a._M_a, std::forward<_Args>(__args)...);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/shared_ptr_base.h:1713:14:   required from 'std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<void>; _Args = {const std::shared_ptr<const PersistentLazySegmentTree<Mini, Ass>::node_t>&, const std::shared_ptr<const PersistentLazySegmentTree<Mini, Ass>::node_t>&, const Mini&, Ass}; _Tp = const PersistentLazySegmentTree<Mini, Ass>::node_t; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]'
 1713 |         : _M_ptr(), _M_refcount(_M_ptr, __tag, std::forward<_Args>(__args)...)
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/shared_ptr.h:463:59:   required from 'std::shared_ptr<_Tp>::shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<void>; _Args = {const std::shared_ptr<const PersistentLazySegmentTree<Mini, Ass>::node_t>&, const std::shared_ptr<const PersistentLazySegmentTree<Mini, Ass>::node_t>&, const Mini&, Ass}; _Tp = const PersistentLazySegmentTree<Mini, Ass>::node_t]'
  463 |         : __shared_ptr<_Tp>(__tag, std::forward<_Args>(__args)...)
      |                                                                  ^
/usr/include/c++/14/bits/shared_ptr.h:1007:14:   required from 'std::shared_ptr<typename std::enable_if<(! std::is_array<_Tp>::value), _Tp>::type> std::make_shared(_Args&& ...) [with _Tp = const PersistentLazySegmentTree<Mini, Ass>::node_t; _Args = {const shared_ptr<const PersistentLazySegmentTree<Mini, Ass>::node_t>&, const shared_ptr<const PersistentLazySegmentTree<Mini, Ass>::node_t>&, const Mini&, Ass}; typename enable_if<(! is_array<_Tp>::value), _Tp>::type = const PersistentLazySegmentTree<Mini, Ass>::node_t]'
 1007 |       return shared_ptr<_Tp>(_Sp_alloc_shared_tag<_Alloc>{__a},
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1008 |                              std::forward<_Args>(__args)...);
      |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:34:41:   required from 'PersistentLazySegmentTree<T, U>::node_t::ptr_type PersistentLazySegmentTree<T, U>::node_t::assign(const PersistentLazySegmentTree<T, U>::operator_type&) const [with T = Mini; U = Ass; ptr_type = std::shared_ptr<const PersistentLazySegmentTree<Mini, Ass>::node_t>; PersistentLazySegmentTree<T, U>::operator_type = Ass]'
   34 |                         return std::make_shared<const node_t>(l, r, value, lazy + data);
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:37:46:   required from 'PersistentLazySegmentTree<T, U>::node_t::ptr_type PersistentLazySegmentTree<T, U>::node_t::update(PersistentLazySegmentTree<T, U>::size_type, PersistentLazySegmentTree<T, U>::size_type, PersistentLazySegmentTree<T, U>::size_type, PersistentLazySegmentTree<T, U>::size_type, const PersistentLazySegmentTree<T, U>::operator_type&, const PersistentLazySegmentTree<T, U>::operator_type&) const [with T = Mini; U = Ass; ptr_type = std::shared_ptr<const PersistentLazySegmentTree<Mini, Ass>::node_t>; PersistentLazySegmentTree<T, U>::size_type = long unsigned int; PersistentLazySegmentTree<T, U>::operator_type = Ass]'
   37 |                         if (right <= first || last <= left)return assign(acc);
      |                                                                   ^~~~~~
a.cc:72:48:   required from 'PersistentLazySegmentTree<T, U> PersistentLazySegmentTree<T, U>::update(size_type, size_type, const operator_type&) const [with T = Mini; U = Ass; size_type = long unsigned int; operator_type = Ass]'
   72 |                 return PersistentLazySegmentTree(root->update(first, last, 0, static_cast<size_type>(1) << height, operator_type(), data),height);
      |                                                  ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:118:16:   required from here
  118 |                         T = T.update(s, t + 1, Ass(x));
      |                             ~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_construct.h:119:7: error: cannot bind rvalue reference of type 'PersistentLazySegmentTree<Mini, Ass>::node_t::ptr_type&&' {aka 'std::shared_ptr<const PersistentLazySegmentTree<Mini, Ass>::node_t>&&'} to lvalue of type 'const std::shared_ptr<const PersistentLazySegmentTree<Mini, Ass>::node_t>'
  119 |       ::new((void*)__p) _Tp(std::forward<_Args>(__args)...);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:25:35: note:   initializing argument 1 of 'PersistentLazySegmentTree<T, U>::node_t::node_t(ptr_type&&, ptr_type&&, PersistentLazySegmentTree<T, U>::value_type&&, PersistentLazySegmentTree<T, U>::operator_type&&) [with T = Mini; U = Ass; ptr_type = std::shared_ptr<const PersistentLazySegmentTree<Mini, Ass>::node_t>; PersistentLazySegmentTree<T, U>::value_type = Mini; PersistentLazySegmentTree<T, U>::operator_type = Ass]'
   25 |                 node_t(ptr_type &&x, ptr_type &&y, value_type &&z, operator_type&&w) :l(std::move(x)), r(std::move(y)), value(std::move(z)), lazy(std::move(w)){}
      |                        ~~~~~~~~~~~^