結果

問題 No.2650 [Cherry 6th Tune *] セイジャク
ユーザー RiRinbaruRiRinbaru
提出日時 2024-02-28 01:39:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 287 ms / 2,500 ms
コード長 2,760 bytes
コンパイル時間 2,630 ms
コンパイル使用メモリ 187,888 KB
実行使用メモリ 9,600 KB
最終ジャッジ日時 2024-02-28 01:40:05
合計ジャッジ時間 14,708 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 101 ms
6,784 KB
testcase_03 AC 22 ms
6,676 KB
testcase_04 AC 140 ms
6,676 KB
testcase_05 AC 115 ms
6,676 KB
testcase_06 AC 60 ms
6,676 KB
testcase_07 AC 111 ms
6,676 KB
testcase_08 AC 49 ms
6,676 KB
testcase_09 AC 262 ms
9,600 KB
testcase_10 AC 269 ms
9,600 KB
testcase_11 AC 261 ms
9,600 KB
testcase_12 AC 259 ms
9,600 KB
testcase_13 AC 261 ms
9,600 KB
testcase_14 AC 287 ms
9,600 KB
testcase_15 AC 262 ms
9,600 KB
testcase_16 AC 225 ms
9,600 KB
testcase_17 AC 223 ms
9,600 KB
testcase_18 AC 225 ms
9,600 KB
testcase_19 AC 253 ms
9,600 KB
testcase_20 AC 226 ms
9,600 KB
testcase_21 AC 229 ms
9,600 KB
testcase_22 AC 223 ms
9,600 KB
testcase_23 AC 203 ms
9,600 KB
testcase_24 AC 213 ms
9,600 KB
testcase_25 AC 202 ms
9,600 KB
testcase_26 AC 202 ms
9,600 KB
testcase_27 AC 203 ms
9,600 KB
testcase_28 AC 205 ms
9,600 KB
testcase_29 AC 209 ms
9,600 KB
testcase_30 AC 237 ms
9,600 KB
testcase_31 AC 221 ms
9,600 KB
testcase_32 AC 175 ms
9,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, p, n) for (ll i = p; i < (ll)(n); i++)
#define rep2(i, p, n) for(ll i = p; i >= (ll)(n); i-- )
using namespace std;
using ll = long long;
using ld = long double;
double pi=3.141592653589793;
const long long inf=2*1e9;
const long long linf=8*1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//atcoder
#include <atcoder/modint>
#include <atcoder/dsu>
#include <atcoder/segtree>
#include <atcoder/lazysegtree>
using namespace atcoder;
using mint1 = modint1000000007;
using mint2 = modint998244353;

/*
//多倍長整数
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using ci = cpp_int;
//ciで定義
//https://boostjp.github.io/tips/multiprec-int.html
//常時使っているとdouble >> llの適切なキャストができない(ll sqrt(整数)等)ので、基本はコメントアウト
*/


//拡張ユークリッド
//input: ll a,b
//output: ax+by=gcd(a,b)の解(x,y)(<max(a, b))
pair<long long, long long> extgcd(long long a, long long b) {
    if (b == 0) return make_pair(1, 0);
    long long x, y;
    tie(y, x) = extgcd(b, a % b);
    y -= a / b * x;
    return make_pair(x, y);
}

//素数列挙
//output: (void)N以下の整数のうち素数であるものをsosuuに返す
void SR(ll N, vector<ll> &sosuu) { 
    vector<bool> testSR(N+1, true);
    for(int i=2; i<=N; i++) {
        if (testSR.at(i)) {
            sosuu.push_back(i);
            for(int j=i*2; j<=N; j+=i) {
                testSR.at(j)=false;
            }
        }
    }
}

ll e() {
    return 0;
}

ll op(ll a, ll b) {
    return a+b;
}

ll mapping(ll f, ll x) {
    if (f==linf) {
        return x;
    }
    return f;
}

ll composition(ll f, ll g) {
    if (f==linf) {
        return g;
    }
    return f;
}

ll id() {
    return linf;
}

int main() {
    ////////////////////
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    ////////////////////

    ll N, A;
    cin >> N >> A;
    vector<pair<ll, ll>> X(N);
    rep(i, 0, N) {
        cin >> X.at(i).first;
        X.at(i).second=i;
    }
    sort(X.begin(), X.end());
    vector<ll> ans(N, -1);
    lazy_segtree<ll, op, e, ll, mapping, composition, id> seg(ans);
    ll T;
    cin >> T;
    rep(i, 0, T) {
    	ll L, R;
    	cin >> L >> R;
    	R++;
    	pair<ll, ll> temp={L, 0};
		ll u=lower_bound(X.begin(), X.end(), temp)-X.begin();
		temp={R, 0};
		ll v=lower_bound(X.begin(), X.end(), temp)-X.begin();
		seg.apply(u, v, i+1);
    }
    vector<ll> G(N);
    rep(i, 0, N) {
        G.at(X.at(i).second)=seg.get(i);
    }
    rep(i, 0, N) {
        cout << G.at(i) << endl;
    }
}
0