#ifndef ONLINE_JUDGE #define _GLIBCXX_DEBUG #endif #include #include #define pass (void)0 #define INF (1<<30)-1 #define INFLL (1LL<<60)-1 using namespace std; using namespace atcoder; using mint = modint998244353; using ll = long long; struct Node { vector> L; int size; }; Node op(Node left, Node right) { vector> A(4, vector (4, 0)); for (int i=0; i<4; i++) { for (int j=i; j<4; j++) { for (int k=i; k> A(4, vector (4, 0)); return Node(A, 0); } Node mapping(int top, Node bottom) { if (top == INF) { return bottom; } vector> A(4, vector (4, 0)); A[top-1][top-1] = bottom.size; return Node(A, bottom.size); } int composition(int top, int bottom) { if (top != INF) { return top; } else { return bottom; } } int id() { return INF; } int main() { int N; cin >> N; vector A(N); for (int i=0; i> A[i]; int Q; cin >> Q; vector B(N); for (int i=0; i> C(4, vector (4, 0)); C[A[i]-1][A[i]-1] = 1; B[i] = Node(C, 1); } lazy_segtree seg(B); while (Q--) { int t, l, r; cin >> t >> l >> r; l --; r --; if (t == 1) { Node n = seg.prod(l, r+1); int ans = 0; for (int i=0; i<4; i++) { for (int j=i; j<4; j++) { ans = max(ans, n.L[i][j]); } } cout << ans << endl; } else { int x; cin >> x; seg.apply(l, r+1, x); } } }