結果

問題 No.2697 Range LIS Query
ユーザー aradarad
提出日時 2024-03-22 23:14:05
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,156 bytes
コンパイル時間 6,188 ms
コンパイル使用メモリ 326,600 KB
実行使用メモリ 129,852 KB
最終ジャッジ日時 2024-03-22 23:14:24
合計ジャッジ時間 18,671 ms
ジャッジサーバーID
(参考情報)
judge14 / 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 249 ms
6,960 KB
testcase_04 AC 240 ms
6,940 KB
testcase_05 AC 240 ms
7,156 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using P = pair<ll,ll>;
using VP = vector<P>;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define out(x) cout << x << endl
#define dout(x) cout << fixed << setprecision(10) << x << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)(x.size())
#define re0 return 0
#define pcnt __builtin_popcountll
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
constexpr int inf = 1e9;
constexpr ll INF = 1e18;
//using mint = modint1000000007;
using mint = modint998244353;

struct S{
    VVL x;
    ll len;
    S():x(4,VL(4)),len(0){}
};

using F = ll;

S op(S a,S b){
    S c;
    rep(d,4)rep(i,4){
        ll j = i+d;
        if(j >= 4) continue;
        for(ll k = i;k <= j;k++)for(ll l = k;l <= j;l++){
            chmax(c.x[i][j],a.x[i][k]+b.x[l][j]);
        }
    }
    c.len = a.len+b.len;
    return c;
}

S e(){
    S res;
    res.len = 0;
    return res;
}

S mapping(F f,S x){
    if(f==INF){
        return x;
    }
    rep(i,4)rep(j,4) x.x[i][j] = 0;
    x.x[f][f] = x.len;
    return x;
}

F composition(F f,F g){
    if(f==INF) return g;
    else return f;
}

F id(){
    return INF;
}

int main(){
    ll n;
    cin >> n;
    vector<S> v(n);
    rep(i,n){
        ll a;
        cin >> a;
        a--;
        v[i].len = 1;
        v[i].x[a][a] = 1;
    }
    lazy_segtree<S,op,e,F,mapping,composition,id> seg(v);
    ll q;
    cin >> q;
    rep(qi,q){
        ll t,l,r;
        cin >> t >> l >> r;
        l--;
        if(t==1){
            ll ans = 0;
            rep(i,4)rep(j,i+1) chmax(ans,seg.prod(l,r).x[j][i]);
            out(ans);
        }
        if(t==2){
            ll x;
            cin >> x;
            x--;
            seg.apply(l,r,x);
        }
    }
}
0