#include #include using namespace std; using namespace atcoder; using ll = long long; //S : 区間の長さ, [l, r] : l~rを使う時のLIS using S = struct{ int first; int second[4][4]; }; using F = int; F ID = -1; S op(S a, S b){ S res; for (int i=0; i<4; i++){ for (int j=0; j<4; j++){ res.second[i][j] = 0; for (int k=i; k<=j; k++){ res.second[i][j] = max(res.second[i][j], a.second[i][k] + b.second[k][j]); } } } res.first = a.first + b.first; return res; } S e() { S res; for (int i=0; i<4; i++){ for (int j=0; j<4; j++) res.second[i][j] = 0; } res.first = 0; return res; } S mapping(F f, S x){ if (f == ID) return x; S res; for (int i=0; i<4; i++){ for (int j=0; j<4; j++){ if (i <= f && f <= j) res.second[i][j] = x.first; else res.second[i][j] = 0; } } res.first = x.first; return res; } F composition(F f, F g){ if (f == ID) return g; else return f; } F id() {return ID;} int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int N, Q, t, l, r, x, A; cin >> N; vector v(N); for (int i=0; i> A; A--; S res; for (int j=0; j<4; j++){ for (int k=0; k<4; k++){ if (j <= A && A <= k) res.second[j][k] = 1; else res.second[j][k] = 0; } } res.first = 1; v[i] = res; } cin >> Q; lazy_segtree tree(v); for (int i=0; i> t; if (t == 1){ cin >> l >> r; l--; cout << tree.prod(l, r).second[0][3] << endl; } else{ cin >> l >> r >> x; x--; l--; tree.apply(l, r, x); } } return 0; }