結果

問題 No.2650 [Cherry 6th Tune *] セイジャク
ユーザー coindarwcoindarw
提出日時 2024-02-23 22:19:16
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 8,458 bytes
コンパイル時間 5,357 ms
コンパイル使用メモリ 318,300 KB
実行使用メモリ 9,852 KB
最終ジャッジ日時 2024-09-29 07:09:55
合計ジャッジ時間 9,365 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,820 KB
testcase_02 RE -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 116 ms
9,724 KB
testcase_31 WA -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifdef ONLINE_JUDGE
#include <bits/stdc++.h>

#include <atcoder/all>
#else
#include <mylibs/all.h>
#endif

using ll = long long;
using lll = __int128_t;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define length(v) ((int)(v).size())
constexpr int inf = 2'000'000'000;
constexpr ll linf = 4'000'000'000'000'000'000, M7 = 1'000'000'007, M9 = 998'244'353;
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)
using namespace std;
using namespace atcoder;

// clang-format off
#define Vec(type, ...) __make_vec<type>(__VA_ARGS__)
template <class T> vector<T> __make_vec(size_t a) {return vector<T>(a);}template <class T, class... Ts>
auto __make_vec(size_t a, Ts... ts) {return vector<decltype(__make_vec<T>(ts...))>(a, __make_vec<T>(ts...));}
#define VecI(init, type, ...) __make_vecI<type, init>(__VA_ARGS__)
template <class T, T init>vector<T> __make_vecI(size_t a) {return vector<T>(a, init);}
template <class T, T init, class... Ts>
auto __make_vecI(size_t a, Ts... ts) {return vector<decltype(__make_vecI<T, init>(ts...))>(a, __make_vecI<T, init>(ts...));}

template <typename T, typename U>inline ostream& operator<<(ostream& os, const pair<T, U>& p) noexcept {return os << p.first << " " << p.second;}
inline ostream& operator<<(ostream& os, const modint& m) noexcept { return os << m.val(); }
template <int M>inline ostream& operator<<(ostream& os, const static_modint<M>& m) noexcept { return os << m.val(); }

template <typename T> struct is_static_modint : std::false_type {}; template <int MOD> struct is_static_modint<static_modint<MOD>> : std::true_type {};
template <template <typename...> typename C, typename Number>concept MyContainer = std::is_same_v<C<Number>, std::vector<Number>> || std::is_same_v<C<Number>, std::deque<Number>> || std::is_same_v<C<Number>, std::set<Number>> || std::is_same_v<C<Number>, std::unordered_set<Number>> || std::is_same_v<C<Number>, std::unordered_multiset<Number>> || std::is_same_v<C<Number>, std::multiset<Number>>;
template <typename Number>concept MyNumber = std::is_same_v<Number, int> || std::is_same_v<Number, ll> || std::is_same_v<Number, char> || std::is_same_v<Number, modint> || is_static_modint<Number>::value;
template <template <typename...> typename C, typename Number>concept MyContainerNumber = MyContainer<C, Number> && MyNumber<Number>;
template <template <typename...> typename OutCon, template <typename...> typename InCon, typename Number>concept MyNestedContainerNumber = MyContainer<OutCon, InCon<Number>> && MyContainerNumber<InCon, Number>;
template <template <typename...> typename C, typename Number>requires MyContainerNumber<C, Number>std::ostream& operator<<(std::ostream& os, const C<Number>& t) {auto itr = t.begin();auto end = t.end();if (itr != end) {os << *itr++;for (; itr != end; ++itr) os << ' ' << *itr;}return os;}
template <template <typename...> typename OutCon, template <typename...> typename InCon, typename Number>requires MyNestedContainerNumber<OutCon, InCon, Number>std::ostream& operator<<(std::ostream& os, const OutCon<InCon<Number>>& t) {auto itr = t.begin();auto end = t.end();if (itr != end) {os << *itr++;for (; itr != end; ++itr) os << '\n' << *itr;}return os;}
template <typename T, typename U>istream& operator>>(istream& is, pair<T, U>& p) {return is >> p.first >> p.second;}
template <typename T>istream& operator>>(istream& is, vector<T>& v) {for (auto& e : v) is >> e;return is;}
void inp() {}
template <typename T, typename... Args>void inp(T& a, Args&... args) {cin >> a, inp(args...);}
template <typename T>void inp1(vector<T>& v, int offset = 1, int len = -1) {if (len == -1) len = int(v.size()) - offset;assert(offset >= 0 && len >= 0);for (int i = offset; i < offset + len; ++i) cin >> v[i];}
template <typename T>void oup(const T& a) {cout << a << "\n";}
template <typename T, typename... Args>void oup(const T& a, const Args&... args) {cout << a << " ", oup(args...);}

inline string YESNO(bool cond) { return cond ? "YES" : "NO"; }inline string yesno(bool cond) { return cond ? "yes" : "no"; }inline string YesNo(bool cond) { return cond ? "Yes" : "No"; }
inline auto add1(auto vec, ll offset = 1) {for (auto& e : vec) e += offset;return vec;}
#ifdef ONLINE_JUDGE
#define debug(...)
#else
#define debug(...) cerr << "<" << #__VA_ARGS__ << ">: ", debug_out(__VA_ARGS__)
template <typename T>void debug_out(T t) {cerr << t << "\n";}
template <typename T, typename... Args>void debug_out(T t, Args... args) {cerr << t << ", ";debug_out(args...);}
#endif

#ifdef ONLINE_JUDGE
#define todo(...) static_assert(false)
#else
#define todo(...)
#endif
// clang-format on

template <class S, S (*op)(S, S), S (*e)(), class F, S (*mapping)(F, S), F (*composition)(F, F), F (*id)()>
class LazySegTree {
   private:
    int _n, n;
    std::vector<S> dat;
    std::vector<F> lazy;
    std::vector<bool> updated;

    S _prod(int a, int b, int p, int l, int r) {
        if (a >= r || b <= l) return e();
        eval(p);
        if (a <= l && r <= b) return dat[p];
        int mid = (l + r) / 2;
        return op(_prod(a, b, p * 2 + 1, l, mid), _prod(a, b, p * 2 + 2, mid, r));
    }

    void _apply(int a, int b, F f, int p, int l, int r) {
        eval(p);
        if (b <= l || r <= a) return;
        else if (a <= l && r <= b) {
            lazy[p] = f;
            updated[p] = true;
            eval(p);
        } else {
            int mid = (l + r) / 2;
            _apply(a, b, f, 2 * p + 1, l, mid);
            _apply(a, b, f, 2 * p + 2, mid, r);
            dat[p] = op(dat[2 * p + 1], dat[2 * p + 2]);
        }
    }
    void eval(int p) {
        if (updated[p]) {
            dat[p] = mapping(lazy[p], dat[p]);
            updated[p] = false;
            if (p < _n - 1) {
                lazy[2 * p + 1] = composition(lazy[p], lazy[2 * p + 1]);
                lazy[2 * p + 2] = composition(lazy[p], lazy[2 * p + 2]);
                updated[2 * p + 1] = updated[2 * p + 2] = true;
            }
            lazy[p] = id();
        }
    }

   public:
    LazySegTree() {}
    LazySegTree(int n) : LazySegTree(std::vector<S>(n, e())) {}
    LazySegTree(const std::vector<S>& v) : n(int(v.size())) {
        this->_n = 1;
        while (this->_n < n) this->_n *= 2;
        dat = std::vector<S>(2 * this->_n - 1, e());
        lazy = std::vector<F>(2 * this->_n - 1, id());
        updated = std::vector<bool>(2 * this->_n - 1);
        for (int i = 0; i < n; i++) dat[i + _n - 1] = v[i];
        for (int i = _n - 2; i >= 0; i--) dat[i] = op(dat[i * 2 + 1], dat[i * 2 + 2]);
    }
    S prod(int l, int r) {
        assert(0 <= l && l <= r && r <= n);
        if (l == r) return e();
        return _prod(l, r, 0, 0, _n);
    }
    S all_prod() { return dat[0]; }
    void apply(int l, int r, F f) {
        assert(0 <= l && l < r && r <= n);
        return _apply(l, r, f, 0, 0, _n);
    }
    S get(int p) {
        assert(0 <= p && p < n);
        return _prod(p, p + 1, 0, 0, _n);
    }

    void print() {
        int lf = 0;
        rep(i, 2 * _n - 1) {
            // cerr << "(" << dat[i].first.first << ", " << dat[i].first.second << ", " << dat[i].second << ")" << "\t";
            eval(i);
            cerr << dat[i] << "\t";
            if (i == lf) {
                lf = lf * 2 + 2;
                cerr << endl;
            }
        }
    }
};

using S = ll;
struct F {
    bool id;
    ll x;
};

S op(S l, S r) { return min(l, r); }

S e() { return inf; }

S mapping(F f, S s) { return f.id ? s : f.x; }

F composition(F f, F g) { return {f.id && g.id, f.id ? g.x : f.x}; }

F id() { return {true, 0ll}; }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, a;
    inp(n, a);
    vector<ll> vx(n);
    inp(vx);
    int t;
    inp(t);

    lazy_segtree<S, op, e, F, mapping, composition, id> seg(vector<S>(n, -1));
    using P = pair<ll, ll>;
    vector<P> vp(t);
    inp(vp);
    rep(i, n) {
        auto [l, r] = vp[i];
        int li = lower_bound(all(vx), l) - vx.begin();
        int ri = upper_bound(all(vx), r) - vx.begin();
        seg.apply(li, ri, {false, i + 1});
    }
    rep(i, n) { cout << seg.get(i) << "\n"; }
    return 0;
}
0