#ifdef NACHIA #define _GLIBCXX_DEBUG #else #define NDEBUG #endif #include #include #include #include #include #include #include #include #include using i64 = long long; using u64 = unsigned long long; #define rep(i,n) for(i64 i=0; i<(i64)(n); i++) #define repr(i,n) for(i64 i=(i64)(n)-1; i>=0; i--) const i64 INF = 1001001001001001001; const char* yn(bool x){ return x ? "Yes" : "No"; } template void chmin(A& l, const A& r){ if(r < l) l = r; } template void chmax(A& l, const A& r){ if(l < r) l = r; } template using nega_queue = std::priority_queue,std::greater>; using Modint = atcoder::static_modint<998244353>; //#include "nachia/vec.hpp" #include using namespace std; #include using Node = array; Node op(Node l, Node r){ Node res; res[0] = l[0] + r[0]; res[1] = max(l[0] + r[1], l[1] + r[4]); res[2] = max(max(l[0] + r[2], l[1] + r[5]), l[2] + r[7]); res[3] = max(max(max(l[0] + r[3], l[1] + r[6]), l[2] + r[8]), l[3] + r[9]); res[4] = l[4] + r[4]; res[5] = max(l[4] + r[5], l[5] + r[7]); res[6] = max(max(l[4] + r[6], l[5] + r[8]), l[6] + r[9]); res[7] = l[7] + r[7]; res[8] = max(l[7] + r[8], l[8] + r[9]); res[9] = l[9] + r[9]; res[10] = l[10] + r[10]; return res; } Node e(){ Node res; res.fill(0); return res; } Node mapping(int f, Node x){ if(f < 0) return x; Node res = e(); res[10] = x[10]; if(f == 0) res[0] = res[1] = res[2] = res[3] = x[10]; else if(f == 1) res[4] = res[5] = res[6] = x[10]; else if(f == 2) res[7] = res[8] = x[10]; else if(f == 3) res[9] = x[10]; return res; } int composition(int l, int r){ if(l < 0) return r; else return l; } int id(){ return -1; } void testcase(){ int N; cin >> N; vector A(N); rep(i,N){ cin >> A[i]; A[i]--; } vector init(N); rep(i,N){ init[i] = e(); init[i][10] = 1; init[i] = mapping(A[i], init[i]); } atcoder::lazy_segtree lst(init); int Q; cin >> Q; rep(qi,Q){ int t; cin >> t; if(t == 1){ int l,r; cin >> l >> r; l--; auto f = lst.prod(l,r); int ans = 0; rep(i,10) chmax(ans, f[i]); cout << ans << '\n'; } else { int l,r,x; cin >> l >> r >> x; l--; x--; lst.apply(l,r,x); } } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); #ifdef NACHIA int T; cin >> T; for(int t=0; t