結果

問題 No.2697 Range LIS Query
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2024-03-22 23:22:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6,807 ms / 10,000 ms
コード長 1,785 bytes
コンパイル時間 3,278 ms
コンパイル使用メモリ 230,640 KB
実行使用メモリ 100,012 KB
最終ジャッジ日時 2024-03-22 23:23:46
合計ジャッジ時間 64,588 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 3 ms
6,676 KB
testcase_03 AC 103 ms
6,676 KB
testcase_04 AC 101 ms
6,676 KB
testcase_05 AC 104 ms
6,676 KB
testcase_06 AC 5,624 ms
100,012 KB
testcase_07 AC 5,543 ms
100,012 KB
testcase_08 AC 5,419 ms
100,012 KB
testcase_09 AC 3,204 ms
100,012 KB
testcase_10 AC 3,298 ms
100,012 KB
testcase_11 AC 3,224 ms
100,012 KB
testcase_12 AC 3,551 ms
96,408 KB
testcase_13 AC 3,958 ms
91,264 KB
testcase_14 AC 5,515 ms
91,904 KB
testcase_15 AC 6,721 ms
100,012 KB
testcase_16 AC 6,749 ms
100,012 KB
testcase_17 AC 6,807 ms
100,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0