結果
問題 | No.2650 [Cherry 6th Tune *] セイジャク |
ユーザー | shobonvip |
提出日時 | 2024-02-23 21:40:42 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 235 ms / 2,500 ms |
コード長 | 3,431 bytes |
コンパイル時間 | 4,569 ms |
コンパイル使用メモリ | 268,032 KB |
実行使用メモリ | 6,676 KB |
最終ジャッジ日時 | 2024-02-23 21:40:55 |
合計ジャッジ時間 | 12,098 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge16 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,676 KB |
testcase_01 | AC | 2 ms
6,676 KB |
testcase_02 | AC | 52 ms
6,676 KB |
testcase_03 | AC | 25 ms
6,676 KB |
testcase_04 | AC | 141 ms
6,676 KB |
testcase_05 | AC | 108 ms
6,676 KB |
testcase_06 | AC | 54 ms
6,676 KB |
testcase_07 | AC | 116 ms
6,676 KB |
testcase_08 | AC | 41 ms
6,676 KB |
testcase_09 | AC | 203 ms
6,676 KB |
testcase_10 | AC | 235 ms
6,676 KB |
testcase_11 | AC | 208 ms
6,676 KB |
testcase_12 | AC | 207 ms
6,676 KB |
testcase_13 | AC | 208 ms
6,676 KB |
testcase_14 | AC | 209 ms
6,676 KB |
testcase_15 | AC | 207 ms
6,676 KB |
testcase_16 | AC | 185 ms
6,676 KB |
testcase_17 | AC | 179 ms
6,676 KB |
testcase_18 | AC | 213 ms
6,676 KB |
testcase_19 | AC | 214 ms
6,676 KB |
testcase_20 | AC | 189 ms
6,676 KB |
testcase_21 | AC | 187 ms
6,676 KB |
testcase_22 | AC | 215 ms
6,676 KB |
testcase_23 | AC | 169 ms
6,676 KB |
testcase_24 | AC | 169 ms
6,676 KB |
testcase_25 | AC | 168 ms
6,676 KB |
testcase_26 | AC | 174 ms
6,676 KB |
testcase_27 | AC | 172 ms
6,676 KB |
testcase_28 | AC | 168 ms
6,676 KB |
testcase_29 | AC | 169 ms
6,676 KB |
testcase_30 | AC | 182 ms
6,676 KB |
testcase_31 | AC | 178 ms
6,676 KB |
testcase_32 | AC | 102 ms
6,676 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; //* ATCODER #include<atcoder/all> using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include<boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) template <typename T> bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template <typename T> bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template <typename T> T max(vector<T> &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template <typename T> T min(vector<T> &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template <typename T> T sum(vector<T> &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } // [ DUAL SEGMENT TREE ] BY SHOBON // REFERENCE --- ATCODER LIBRARY // VERSION 1.0 (2022/08/28) int ceil_pow2(int n) { int x = 0; while ((1U << x) < (unsigned int)(n)) x++; return x; } template <class F, F (*composition)(F, F), F (*id)()> struct dual_segtree{ public: dual_segtree() : dual_segtree(0) {} explicit dual_segtree(int n) : dual_segtree(std::vector<F>(n, id())) {} explicit dual_segtree(const std::vector<F>& v) : _n(int(v.size())) { log = ceil_pow2(_n); size = 1 << log; lz = std::vector<F>(2 * size, id()); for (int i = 0; i < _n; i++) lz[size + i] = v[i]; } void apply(int l, int r, F f){ assert (0 <= l && l <= r && r <= _n); if (l == r) return; l += size; r += size; for (int i = log; i >= 1; i--){ if (((l >> i) << i) != l) push(l >> i); if (((r >> i) << i) != r) push((r - 1) >> i); } while (l < r){ if (l & 1) all_apply(l++, f); if (r & 1) all_apply(--r, f); l >>= 1; r >>= 1; } } F get(int p) { assert(0 <= p && p < _n); p += size; for (int i = log; i >= 1; i--) push(p >> i); return lz[p]; } private: int _n, size, log; std::vector<F> lz; void all_apply(int k, F f){ lz[k] = composition(f, lz[k]); } void push(int k){ all_apply(2 * k, lz[k]); all_apply(2 * k + 1, lz[k]); lz[k] = id(); } }; // ---- END : DUAL SEGMENT TREE ---- int id(){ return -1; } int composition(int i, int j){ if (i == id()) return j; return i; } // defcomp template <typename T> vector<T> compress(vector<T> &X) { vector<T> vals = X; sort(vals.begin(), vals.end()); vals.erase(unique(vals.begin(), vals.end()), vals.end()); return vals; } // ----- // importbisect template <typename T> int bisect_left(vector<T> &X, T v){ return lower_bound(X.begin(), X.end(), v) - X.begin(); } template <typename T> int bisect_right(vector<T> &X, T v){ return upper_bound(X.begin(), X.end(), v) - X.begin(); } // ----- int main(){ int n; cin >> n; ll a; cin >> a; vector<ll> x(n); rep(i,0,n) cin >> x[i]; vector<ll> c = compress(x); int m = c.size(); int t; cin >> t; dual_segtree<int,composition,id> seg(m); rep(i,0,t){ ll l, r; cin >> l >> r; int ls = bisect_left(c, l); int rs = bisect_right(c, r); seg.apply(ls,rs,i+1); } rep(i,0,n){ cout << seg.get(bisect_left(c, x[i])) << '\n'; } }