結果

問題 No.2650 [Cherry 6th Tune *] セイジャク
ユーザー maeshunmaeshun
提出日時 2024-02-26 23:18:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 382 ms / 2,500 ms
コード長 1,748 bytes
コンパイル時間 4,034 ms
コンパイル使用メモリ 269,792 KB
実行使用メモリ 15,752 KB
最終ジャッジ日時 2024-02-26 23:19:03
合計ジャッジ時間 16,180 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 1 ms
6,548 KB
testcase_02 AC 117 ms
6,548 KB
testcase_03 AC 37 ms
6,548 KB
testcase_04 AC 220 ms
10,024 KB
testcase_05 AC 171 ms
9,180 KB
testcase_06 AC 97 ms
6,548 KB
testcase_07 AC 175 ms
9,368 KB
testcase_08 AC 69 ms
6,548 KB
testcase_09 AC 355 ms
15,752 KB
testcase_10 AC 362 ms
15,752 KB
testcase_11 AC 373 ms
15,752 KB
testcase_12 AC 356 ms
15,752 KB
testcase_13 AC 349 ms
15,752 KB
testcase_14 AC 382 ms
15,752 KB
testcase_15 AC 361 ms
15,752 KB
testcase_16 AC 330 ms
15,752 KB
testcase_17 AC 335 ms
15,752 KB
testcase_18 AC 358 ms
15,752 KB
testcase_19 AC 354 ms
15,752 KB
testcase_20 AC 338 ms
15,752 KB
testcase_21 AC 335 ms
15,752 KB
testcase_22 AC 354 ms
15,752 KB
testcase_23 AC 304 ms
15,752 KB
testcase_24 AC 315 ms
15,752 KB
testcase_25 AC 308 ms
15,752 KB
testcase_26 AC 316 ms
15,752 KB
testcase_27 AC 320 ms
15,752 KB
testcase_28 AC 313 ms
15,752 KB
testcase_29 AC 336 ms
15,752 KB
testcase_30 AC 313 ms
15,752 KB
testcase_31 AC 320 ms
15,752 KB
testcase_32 AC 210 ms
7,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for(int i=0;i<(n);++i)
#define rep1(i, n) for(int i=1;i<=(n);i++)
#define ll long long
using mint = modint998244353;
using P = pair<ll,ll>;
using lb = long double;
using T = tuple<ll, ll, ll>;
#ifdef LOCAL
#  include <debug_print.hpp>
#  define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#  define dbg(...) (static_cast<void>(0))
#endif

// Coodinate Compression
// https://youtu.be/fR3W5IcBGLQ?t=8550
template<typename T=long long>
struct CC {
  bool initialized;
  vector<T> xs;
  CC(): initialized(false) {}
  void add(T x) { xs.push_back(x);}
  void init() {
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(),xs.end()),xs.end());
    initialized = true;
  }
  int operator()(T x) {
    if (!initialized) init();
    return upper_bound(xs.begin(), xs.end(), x) - xs.begin() - 1;
  }
  T operator[](int i) {
    if (!initialized) init();
    return xs[i];
  }
  int size() {
    if (!initialized) init();
    return xs.size();
  }
};

int op(int a, int b) {
	return max(a,b);
}

int e(){
	return -1;
}

int mapping(int d, int a){
	if(d==0) return a;
	else return d;
}

int composition(int a, int b) {
	if(a==0) return b;
	else return a;
}

int id() {
	return 0;
}

int main()
{
	int n, a;
	cin >> n >> a;
	vector<int> x(n);
	rep(i,n) cin >> x[i];
	int t;
	cin >> t;
	vector<int> l(t),r(t);
	rep(i,t) cin >> l[i] >> r[i];
	CC cc;
	rep(i,n) cc.add(x[i]);
	rep(i,t){
		cc.add(l[i]);
		cc.add(r[i]);
	}
	int m = cc.size();
	lazy_segtree<int, op, e, int, mapping, composition, id> seg(m);
	rep(i,t){
		seg.apply(cc(l[i]), cc(r[i])+1, i+1);
	}
	rep(i,n){
		cout<<seg.get(cc(x[i]))<<endl;
	}
	return 0;
}
0