結果

問題 No.2697 Range LIS Query
ユーザー 👑 NachiaNachia
提出日時 2024-03-22 23:12:22
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 197 ms / 10,000 ms
コード長 2,739 bytes
コンパイル時間 1,297 ms
コンパイル使用メモリ 120,752 KB
実行使用メモリ 19,772 KB
最終ジャッジ日時 2024-09-30 12:27:15
合計ジャッジ時間 4,654 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#ifdef NACHIA
#define _GLIBCXX_DEBUG
#else
#define NDEBUG
#endif
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <array>
#include <cmath>
#include <atcoder/modint>
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(i64 i=0; i<(i64)(n); i++)
#define repr(i,n) for(i64 i=(i64)(n)-1; i>=0; i--)
const i64 INF = 1001001001001001001;
const char* yn(bool x){ return x ? "Yes" : "No"; }
template<typename A> void chmin(A& l, const A& r){ if(r < l) l = r; }
template<typename A> void chmax(A& l, const A& r){ if(l < r) l = r; }
template<typename A> using nega_queue = std::priority_queue<A,std::vector<A>,std::greater<A>>;
using Modint = atcoder::static_modint<998244353>;
//#include "nachia/vec.hpp"
#include <atcoder/dsu>
using namespace std;
#include <atcoder/lazysegtree>
using Node = array<int, 11>;
Node op(Node l, Node r){
Node res;
res[0] = l[0] + r[0];
res[1] = max(l[0] + r[1], l[1] + r[4]);
res[2] = max(max(l[0] + r[2], l[1] + r[5]), l[2] + r[7]);
res[3] = max(max(max(l[0] + r[3], l[1] + r[6]), l[2] + r[8]), l[3] + r[9]);
res[4] = l[4] + r[4];
res[5] = max(l[4] + r[5], l[5] + r[7]);
res[6] = max(max(l[4] + r[6], l[5] + r[8]), l[6] + r[9]);
res[7] = l[7] + r[7];
res[8] = max(l[7] + r[8], l[8] + r[9]);
res[9] = l[9] + r[9];
res[10] = l[10] + r[10];
return res;
}
Node e(){ Node res; res.fill(0); return res; }
Node mapping(int f, Node x){
if(f < 0) return x;
Node res = e(); res[10] = x[10];
if(f == 0) res[0] = res[1] = res[2] = res[3] = x[10];
else if(f == 1) res[4] = res[5] = res[6] = x[10];
else if(f == 2) res[7] = res[8] = x[10];
else if(f == 3) res[9] = x[10];
return res;
}
int composition(int l, int r){ if(l < 0) return r; else return l; }
int id(){ return -1; }
void testcase(){
int N; cin >> N;
vector<int> A(N); rep(i,N){ cin >> A[i]; A[i]--; }
vector<Node> init(N);
rep(i,N){
init[i] = e();
init[i][10] = 1;
init[i] = mapping(A[i], init[i]);
}
atcoder::lazy_segtree<Node, op, e, int, mapping, composition, id> lst(init);
int Q; cin >> Q;
rep(qi,Q){
int t; cin >> t;
if(t == 1){
int l,r; cin >> l >> r; l--;
auto f = lst.prod(l,r);
int ans = 0;
rep(i,10) chmax(ans, f[i]);
cout << ans << '\n';
} else {
int l,r,x; cin >> l >> r >> x; l--; x--;
lst.apply(l,r,x);
}
}
}
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
#ifdef NACHIA
int T; cin >> T; for(int t=0; t<T; T!=++t?(cout<<'\n'),0:0)
#endif
testcase();
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0