結果
| 問題 |
No.2650 [Cherry 6th Tune *] セイジャク
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-26 20:47:04 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 144 ms / 2,500 ms |
| コード長 | 1,716 bytes |
| コンパイル時間 | 2,981 ms |
| コンパイル使用メモリ | 265,976 KB |
| 実行使用メモリ | 8,824 KB |
| 最終ジャッジ日時 | 2024-09-29 11:45:05 |
| 合計ジャッジ時間 | 9,598 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/lazysegtree>
using namespace std;
using namespace atcoder;
using ll = long long;
template<typename T, typename S, auto op, auto e, typename F, auto fx, auto fg, auto id> struct CompressedLazySegTree {
private:
lazy_segtree<S, op, e, F, fx, fg, id> seg;
vector<T> s;
int idx(T x) { return ranges::lower_bound(s, x) - s.begin(); }
public:
void use(T x) { s.emplace_back(x); }
void build() {
ranges::sort(s);
s.erase(unique(s.begin(), s.end()), s.end());
seg = lazy_segtree<S, op, e, F, fx, fg, id>(s.size());
}
void set(T i, S x) { seg.set(idx(i), x); }
S get(T i) { return seg.get(idx(i)); }
S prod(T l, T r) { return seg.prod(idx(l), idx(r)); }
S all_prod() { return seg.all_prod(); }
void apply(T i, F f) { seg.apply(idx(i), f); }
void apply(T l, T r, F f) { seg.apply(idx(l), idx(r), f); }
template<auto f> int max_right(T l) {
return seg.max_right(idx(l), [](S x) { return f(x); });
}
template<auto f> int min_left(T r) {
return seg.min_left(idx(r), [](S x) { return f(x); });
}
};
using S = ll;
using F = ll;
S op(S l, S r) { return max(l, r); }
S e() { return -1; }
S fx(F f, S x) { return (f == 1e18 ? x : f); }
F fg(F f, F g) { return (f == 1e18 ? g : f); }
F id() { return 1e18; }
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll N, A;
cin >> N >> A;
CompressedLazySegTree<ll, S, op, e, F, fx, fg, id> seg;
vector<ll> X(N);
for(auto &i : X) {
cin >> i;
seg.use(i);
}
seg.build();
ll Q;
cin >> Q;
for(ll i = 0; i < Q; i++) {
ll l, r;
cin >> l >> r;
r++;
seg.apply(l, r, i + 1);
}
for(ll i = 0; i < N; i++) { cout << seg.get(X[i]) << "\n"; }
}