結果

問題 No.2650 [Cherry 6th Tune *] セイジャク
ユーザー ooaiu
提出日時 2024-12-07 11:24:08
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 133 ms / 2,500 ms
コード長 1,248 bytes
コンパイル時間 3,621 ms
コンパイル使用メモリ 258,464 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2024-12-07 11:24:20
合計ジャッジ時間 11,994 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifndef LOCAL
#include <bits/stdc++.h>

using namespace std;

#define debug(...) (void(0))
#else
#include "algo/debug.h"
#endif

#include <atcoder/lazysegtree>
int id() { return -1; }
int mapping(int f, int x) {
    if (f != id()) return f;
    return x;
}
int comp(int f, int g) {
    return (f == id() ? g : f);
}
void solve() {
    int N, A;
    cin >> N >> A;
    vector<pair<int, int>> X(N);
    for (int i = 0; i < N; i++) {
        cin >> X[i].first;
        X[i].second = i;
    }
    sort(X.begin(), X.end());
    vector<int> Y(N);
    for (int i = 0; i < N; i++) Y[i] = X[i].first;
    atcoder::lazy_segtree<int, mapping, id, int, mapping, comp, id> seg(N);
    int T;
    cin >> T;
    for (int t = 1; t <= T; t++) {
        int L, R;
        cin >> L >> R;
        int l = distance(Y.begin(), lower_bound(Y.begin(), Y.end(), L));
        int r = distance(Y.begin(), upper_bound(Y.begin(), Y.end(), R));
        seg.apply(l, r, t);
    }
    vector<int> ans(N);
    for (int i = 0; i < N; i++) ans[X[i].second] = seg.get(i);
    for (const auto& x : ans) cout << x << '\n';
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int tt = 1;
    // std::cin >> tt;
    while (tt--) {
        solve();
    }
}
0