結果
問題 |
No.2697 Range LIS Query
|
ユーザー |
|
提出日時 | 2024-10-05 17:35:44 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 268 ms / 10,000 ms |
コード長 | 1,532 bytes |
コンパイル時間 | 2,706 ms |
コンパイル使用メモリ | 254,240 KB |
実行使用メモリ | 27,776 KB |
最終ジャッジ日時 | 2024-10-05 17:35:54 |
合計ジャッジ時間 | 6,422 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/lazysegtree> constexpr int N = 4; struct S { int len{}; array<array<int, N>, N> d{}; }; S e() { return S{}; } S op(S a, S b) { S ret = e(); ret.len = a.len + b.len; for (int i = 0; i < N; i++) { for (int j = i; j < N; j++) { for (int k = i; k <= j; k++) { ret.d[i][j] = max(ret.d[i][j], a.d[i][k] + b.d[k][j]); } } } return ret; } using F = int; F id() { return -1; } S mp(F f, S x) { if (f == id()) return x; S ret = e(); ret.len = x.len; f--; for (int i = 0; i <= f; i++) { for (int j = f; j < N; j++) { ret.d[i][j] = x.len; } } return ret; } F cmp(F f, F g) { return (f == id() ? g : f); } int main() { constexpr char endl = '\n'; std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; cin >> n; vector<S> init(n); for (int i = 0; i < n; i++) { int a; cin >> a; a--; init[i].len = 1; for (int j = 0; j <= a; j++) { for (int k = a; k < N; k++) { init[i].d[j][k] = 1; } } } atcoder::lazy_segtree<S, op, e, F, mp, cmp, id> seg(init); int q; cin >> q; while (q--) { int t; cin >> t; int l, r; cin >> l >> r; l--; if (t == 1) { S ret = seg.prod(l, r); int ans = 0; for (int i = 0; i < N; i++) for (int j = i; j < N; j++) ans = max(ans, ret.d[i][j]); cout << ans << endl; } else { int x; cin >> x; seg.apply(l, r, x); } } }