Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- // tiom4eg's precompiler options
- // POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS
- // IO settings
- #define fastIO ios_base::sync_with_stdio(false); cin.tie(0)
- // Quick types
- #define ll long long
- #define ld long double
- #define ull unsigned long long
- #define pii pair <int, int>
- #define vi vector <int>
- #define mi vector <vector <int>>
- // Quick functions
- #define endl "\n"
- #define F first
- #define S second
- #define all(a) a.begin(), a.end()
- #define sz(a) (int)(a.size())
- #define pb push_back
- #define mp make_pair
- // Quick fors
- #define FOR(i, a, b) for (int i = a; i < b; ++i)
- #define FORS(i, a, b, c) for (int i = a; i < b; i += c)
- #define RFOR(i, a, b) for (int i = a; i >= b; --i)
- #define EACH(e, a) for (auto& e : a)
- // Pragmas
- #ifndef TIOM4EG
- #pragma GCC optimize("O3,unroll-loops") // let the chaos begin!
- #pragma GCC target("avx,avx2,bmi,bmi2,popcnt,lzcnt,tune=native")
- #pragma GCC comment(linker, "/stack:200000000")
- #endif
- // PBDS
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- #define ordered_set tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update>
- #define ook order_of_key
- #define fbo find_by_order
- using namespace __gnu_pbds;
- // POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS
- using namespace std;
- mt19937 rng(chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count());
- //#define int long long
- const int INF = 1e9 + 7, INFLL = 1e13 + 7, MD = 998244353, R = 1 << 18, MOD = 1e9 + 7, MAX = 300009, LG = 30, B = 31, S = 10008;
- int mnpt[2 * R], mxpt[2 * R], tott[2 * R], totp[2 * R], prp[2 * R];
- void merge(int v) { mnpt[v] = min(mnpt[2 * v], mnpt[2 * v + 1]), mxpt[v] = max(mxpt[2 * v], mxpt[2 * v + 1]), tott[v] = tott[2 * v] + tott[2 * v + 1]; }
- void push(int v, int l) {
- if (v >= R) return;
- if (prp[v] != -1) mnpt[2 * v] = mxpt[2 * v] = mnpt[2 * v + 1] = mxpt[2 * v + 1] = prp[2 * v] = prp[2 * v + 1] = prp[v];
- if (totp[v]) tott[2 * v] += totp[v] * (l / 2), tott[2 * v + 1] += totp[v] * (l / 2), totp[2 * v] += totp[v], totp[2 * v + 1] += totp[v];
- prp[v] = -1, totp[v] = 0;
- }
- void build() { FOR(i, 1, 2 * R) mnpt[i] = mxpt[i] = INF, prp[i] = -1; }
- void add(int ql, int qr, int x, int v = 1, int nl = 0, int nr = R) {
- push(v, nr - nl);
- if (nr <= ql || qr <= nl || mxpt[v] < x) return;
- if (ql <= nl && nr <= qr && mnpt[v] > x) {
- mnpt[v] = mxpt[v] = prp[v] = x;
- push(v, nr - nl);
- return;
- }
- int nm = (nl + nr) / 2;
- add(ql, qr, x, 2 * v, nl, nm), add(ql, qr, x, 2 * v + 1, nm, nr);
- merge(v);
- }
- void del(int ql, int qr, int x, int v = 1, int nl = 0, int nr = R) {
- push(v, nr - nl);
- if (nr <= ql || qr <= nl || mnpt[v] == INF) return;
- if (ql <= nl && nr <= qr && mnpt[v] == mxpt[v]) {
- totp[v] += x - mnpt[v], tott[v] += (nr - nl) * (x - mnpt[v]);
- mnpt[v] = mxpt[v] = prp[v] = INF;
- push(v, nr - nl);
- return;
- }
- int nm = (nl + nr) / 2;
- del(ql, qr, x, 2 * v, nl, nm), del(ql, qr, x, 2 * v + 1, nm, nr);
- merge(v);
- }
- int get(int ql, int qr, int v = 1, int nl = 0, int nr = R) {
- push(v, nr - nl);
- if (nr <= ql || qr <= nl) return 0;
- if (ql <= nl && nr <= qr) return tott[v];
- int nm = (nl + nr) / 2;
- return get(ql, qr, 2 * v, nl, nm) + get(ql, qr, 2 * v + 1, nm, nr);
- }
- signed main() {
- fastIO;
- int n, q; cin >> n >> q;
- build();
- FOR(i, 0, q) {
- char op; int l, r; cin >> op >> l >> r, --l;
- if (op == '+') add(l, r, i);
- else del(l, r, i);
- }
- del(0, n, q);
- FOR(i, 0, n) cout << q - get(i, i + 1) << ' ';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement