結果

問題 No.2697 Range LIS Query
ユーザー aradarad
提出日時 2024-03-22 23:19:30
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,695 ms / 10,000 ms
コード長 2,386 bytes
コンパイル時間 7,810 ms
コンパイル使用メモリ 338,924 KB
実行使用メモリ 52,544 KB
最終ジャッジ日時 2024-03-22 23:20:32
合計ジャッジ時間 22,684 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 25 ms
6,676 KB
testcase_04 AC 23 ms
6,676 KB
testcase_05 AC 23 ms
6,676 KB
testcase_06 AC 1,031 ms
52,544 KB
testcase_07 AC 1,029 ms
52,544 KB
testcase_08 AC 973 ms
52,544 KB
testcase_09 AC 1,675 ms
52,544 KB
testcase_10 AC 1,692 ms
52,544 KB
testcase_11 AC 1,695 ms
52,544 KB
testcase_12 AC 527 ms
50,752 KB
testcase_13 AC 637 ms
48,112 KB
testcase_14 AC 879 ms
48,432 KB
testcase_15 AC 1,044 ms
52,544 KB
testcase_16 AC 1,039 ms
52,544 KB
testcase_17 AC 1,053 ms
52,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#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{
    ll x[4][4];
    ll len;
    S():len(0){
        rep(i,4)rep(j,i+1) x[j][i] = 0;
    }
};

using F = ll;

S op(S a,S b){
    S c;
    rep(d,4)for(ll i = 0;i+d < 4;i++){
        ll j = i+d;
        if(j >= 4) continue;
        ll mx = 0;
        for(ll k = i;k <= j;k++){
            chmax(mx,a.x[i][k]);
            chmax(c.x[i][j],mx+b.x[k][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,i+1) x.x[j][i] = 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(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    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