結果
問題 | No.2697 Range LIS Query |
ユーザー | srjywrdnprkt |
提出日時 | 2024-03-22 23:59:08 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 501 ms / 10,000 ms |
コード長 | 1,938 bytes |
コンパイル時間 | 3,855 ms |
コンパイル使用メモリ | 217,568 KB |
実行使用メモリ | 27,744 KB |
最終ジャッジ日時 | 2024-03-22 23:59:20 |
合計ジャッジ時間 | 9,013 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
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 | 12 ms
6,676 KB |
testcase_04 | AC | 11 ms
6,676 KB |
testcase_05 | AC | 12 ms
6,676 KB |
testcase_06 | AC | 428 ms
27,744 KB |
testcase_07 | AC | 403 ms
27,744 KB |
testcase_08 | AC | 430 ms
27,744 KB |
testcase_09 | AC | 399 ms
27,744 KB |
testcase_10 | AC | 426 ms
27,744 KB |
testcase_11 | AC | 400 ms
27,744 KB |
testcase_12 | AC | 240 ms
26,848 KB |
testcase_13 | AC | 274 ms
25,592 KB |
testcase_14 | AC | 407 ms
25,752 KB |
testcase_15 | AC | 450 ms
27,744 KB |
testcase_16 | AC | 482 ms
27,744 KB |
testcase_17 | AC | 501 ms
27,744 KB |
ソースコード
#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 = struct{ int first; int second[4][4]; }; using F = int; F ID = -1; S op(S a, S b){ S res; for (int i=0; i<4; i++){ for (int j=0; j<4; j++){ res.second[i][j] = 0; for (int k=i; k<=j; k++){ res.second[i][j] = max(res.second[i][j], a.second[i][k] + b.second[k][j]); } } } res.first = a.first + b.first; return res; } S e() { S res; for (int i=0; i<4; i++){ for (int j=0; j<4; j++) res.second[i][j] = 0; } res.first = 0; return res; } S mapping(F f, S x){ if (f == ID) return x; S res; for (int i=0; i<4; i++){ for (int j=0; j<4; j++){ if (i <= f && f <= j) res.second[i][j] = x.first; else res.second[i][j] = 0; } } res.first = x.first; return 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--; S res; for (int j=0; j<4; j++){ for (int k=0; k<4; k++){ if (j <= A && A <= k) res.second[j][k] = 1; else res.second[j][k] = 0; } } res.first = 1; v[i] = 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; }