結果

問題 No.2650 [Cherry 6th Tune *] セイジャク
ユーザー kusaf_kusaf_
提出日時 2024-02-26 20:47:04
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 174 ms / 2,500 ms
コード長 1,716 bytes
コンパイル時間 3,332 ms
コンパイル使用メモリ 266,272 KB
実行使用メモリ 8,820 KB
最終ジャッジ日時 2024-02-26 20:47:16
合計ジャッジ時間 11,764 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 39 ms
6,676 KB
testcase_03 AC 18 ms
6,676 KB
testcase_04 AC 104 ms
6,676 KB
testcase_05 AC 78 ms
6,676 KB
testcase_06 AC 40 ms
6,676 KB
testcase_07 AC 82 ms
6,676 KB
testcase_08 AC 29 ms
6,676 KB
testcase_09 AC 164 ms
8,820 KB
testcase_10 AC 171 ms
8,820 KB
testcase_11 AC 170 ms
8,820 KB
testcase_12 AC 153 ms
8,820 KB
testcase_13 AC 153 ms
8,820 KB
testcase_14 AC 146 ms
8,820 KB
testcase_15 AC 174 ms
8,820 KB
testcase_16 AC 111 ms
8,820 KB
testcase_17 AC 105 ms
8,820 KB
testcase_18 AC 108 ms
8,820 KB
testcase_19 AC 110 ms
8,820 KB
testcase_20 AC 108 ms
8,820 KB
testcase_21 AC 107 ms
8,820 KB
testcase_22 AC 107 ms
8,820 KB
testcase_23 AC 93 ms
8,820 KB
testcase_24 AC 104 ms
8,820 KB
testcase_25 AC 99 ms
8,820 KB
testcase_26 AC 97 ms
8,820 KB
testcase_27 AC 95 ms
8,820 KB
testcase_28 AC 91 ms
8,820 KB
testcase_29 AC 93 ms
8,820 KB
testcase_30 AC 113 ms
8,820 KB
testcase_31 AC 117 ms
8,820 KB
testcase_32 AC 68 ms
8,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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"; }
}
0