結果
| 問題 |
No.2650 [Cherry 6th Tune *] セイジャク
|
| コンテスト | |
| ユーザー |
maeshun
|
| 提出日時 | 2024-02-26 23:18:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 436 ms / 2,500 ms |
| コード長 | 1,748 bytes |
| コンパイル時間 | 4,447 ms |
| コンパイル使用メモリ | 258,028 KB |
| 最終ジャッジ日時 | 2025-02-19 21:38:18 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 31 |
ソースコード
#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;
}
maeshun