結果
| 問題 | No.2697 Range LIS Query | 
| コンテスト | |
| ユーザー |  srjywrdnprkt | 
| 提出日時 | 2024-03-22 23:22:38 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 7,202 ms / 10,000 ms | 
| コード長 | 1,785 bytes | 
| コンパイル時間 | 3,023 ms | 
| コンパイル使用メモリ | 220,272 KB | 
| 最終ジャッジ日時 | 2025-02-20 12:41:29 | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 15 | 
ソースコード
#include <bits/stdc++.h>
#include <atcoder/lazysegtree>
using namespace std;
using namespace atcoder;
using ll = long long;
//S : 区間の長さ, [l, r] : l~rを使う時のLIS
using S = pair<int, vector<vector<int>>>;
using F = int;
F ID = -1;
S op(S a, S b){
    vector res(4, vector<int>(4, 0));
    for (int i=0; i<4; i++){
        for (int j=0; j<4; j++){
            for (int k=i; k<=j; k++){
                res[i][j] = max(res[i][j], a.second[i][k] + b.second[k][j]);
            }
        }
    }
    return {a.first + b.first, res};
}
S e() {return {0, vector(4, vector<int>(4, 0))};}
S mapping(F f, S x){
    if (f == ID) return x;
    vector res(4, vector<int>(4, 0));
    for (int i=0; i<4; i++){
        for (int j=0; j<4; j++){
            if (i <= f && f <= j) res[i][j] = x.first;
            else res[i][j] = 0;
        }
    }
    return {x.first, 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<S> v(N);
    for (int i=0; i<N; i++){
        cin >> A; A--;
        vector res(4, vector<int>(4, 0));
        for (int j=0; j<4; j++){
            for (int k=0; k<4; k++){
                if (j <= A && A <= k) res[j][k] = 1;
                else res[j][k] = 0;
            }
        }
        v[i] = {1, res};
    }
    cin >> Q;
    lazy_segtree<S, op, e, F, mapping, composition, id> tree(v);
    for (int i=0; i<Q; i++){
        cin >> 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;
}
            
            
            
        