/** * author: USERNAME * created: yyyy-mm-dd hh:mm:ss **/ #include using namespace std; #include using namespace atcoder; // clang-format off /* accelration */ // 高速バイナリ生成 #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") // cin cout の結びつけ解除, stdioと同期しない(入出力非同期化) // cとstdの入出力を混在させるとバグるので注意 struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast; /* alias */ // type using ull = unsigned long long; using ll = long long; using ld = long double; // pair using pii = pair; // vector using vi = vector; using vl = vector; using vll = vector; using vvi = vector; using vvl = vector; using vvll = vector; using vs = vector; using vpii = vector; // unordered set using usi = unordered_set; using usll = unordered_set; using uss = unordered_set; /* define short */ #define pb push_back #define mp make_pair #define um unordered_map #define all(obj) (obj).begin(), (obj).end() #define YESNO(bool) if(bool){cout<<"YES"<=0;i--) #define rrepd(i,n) for(ll i=n;i>=1;i--) /* debug */ // 標準エラー出力を含む提出はrejectされる場合もあるので注意 #define debug(x) cerr << "\033[33m(line:" << __LINE__ << ") " << #x << ": " << x << "\033[m" << endl; /* func */ inline int in_int() {int x; cin >> x; return x;} inline ll in_ll() {ll x; cin >> x; return x;} inline double in_double() {{double x; cin >> x; return x;}} inline string in_str() {string x; cin >> x; return x;} inline int ctoi(char c) {return c - '0';} // vector_finder: (arg)elementを vectorの先頭から(arg)search_lengthまで先頭から検索し、boolを返す // (arg)search_length: 走査するベクトル長の上限(先頭から何要素目までを検索対象とするか、1始まりで) template inline bool vector_finder(std::vector vec, T element, unsigned int search_length) { auto itr = std::find(vec.begin(), vec.end(), element); size_t index = std::distance( vec.begin(), itr ); if (index == vec.size() || index >= search_length) {return false;} else {return true;} } template inline void print(const vector& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");} template inline void print(const pair& p) {cout << p.first << " " << p.second << endl;} template inline void print(const T& x) {cout << x << "\n";} template inline void print(const vector>& v) {for (auto&& p : v) print(p);} template inline void print(const map& m) {for (auto&& p : m) print(p);} // 第一引数と第二引数を比較し、第一引数(a)をより大きい/小さい値に上書き template inline bool chmin(T& a, const T& b) {bool compare = a > b; if (a > b) a = b; return compare;} template inline bool chmax(T& a, const T& b) {bool compare = a < b; if (a < b) a = b; return compare;} // gcd lcm // C++17からは標準実装 // template T gcd(T a, T b) {if (b == 0)return a; else return gcd(b, a % b);} // template inline T lcm(T a, T b) {return (a * b) / gcd(a, b);} // clang-format on struct S{ int value; int size; }; using F = bool; S op(S a, S b){ return {a.value + b.value, a.size + b.size}; } S mapping(F f, S x){ if (f){ return {x.size - x.value, x.size}; } else { return x; } } F composition(F f, F g){ return f ^ g; } S e(){ return {0, 0}; } F id(){ return false; } int main() { auto N = in_int(); auto Q = in_int(); vi A(N); rep(idx, N){ A.at(idx) = in_int(); } vector seg_elm; for (const auto& a_elm : A){ seg_elm.push_back({a_elm, 1}); } atcoder::lazy_segtree seg_tree(seg_elm); rep(_, Q){ auto L = in_int() - 1; auto R = in_int(); seg_tree.apply(L, R, true); } rep(idx, N){ cout << seg_tree.get(idx).value << " "; } cout << endl; return 0; }