Da Da se divide en discusiones, y las ideas aún son muy inteligentes.
código:
#include <bits / stdc ++. h> #define ll long long #define lson now << 1 #define rson now << 1 | 1 #define N 100008 #define mod 998244353 #define setIO (s) freopen (s ".in "," r ", stdin) usando el espacio de nombres std; int n, m, cur; ll f [N << 3], g [N << 3], SUM [N << 3], qp [N], mf [N << 3], mg [N << 3]; vacío markf (int ahora, int v) { f [ahora] = (ll) f [ahora] * qp [v]% mod; SUMA [ahora] = (ll) SUMA [ahora] * qp [v]% mod; mf [ahora] + = v; } vacío markg (int ahora, int v) { g [ahora] = (ll) g [ahora] * qp [v]% mod; mg [ahora] + = v; if (mf [ahora]) { markf (lson, mf [ahora]); markf (rson, mf [ahora]); mf [ahora] = 0; } if (mg [ahora]) { markg (lson, mg [ahora]); markg (rson, mg [ahora]); mg [ahora] = 0; } } vacío pushup (int ahora) { SUM [ahora] = (ll) (SUM [lson] + SUM [rson] + f [ahora])% mod; } construcción vacía (int l, int r, int ahora) { f [ahora] = 0, g [ahora] = 1; si (l == r) devuelve; int mid = (l + r) >> 1; build (l, mid, lson), build (mid + 1, r, rson); } actualización nula (int l, int r, int now, int L, int R) { pushdown (ahora); if (l> = L && r <= R) pushdown (p); { // 1 类 点 f [ahora] = (ll) (f [ahora] + qp [cur-1])% mod; markf (lson, 1), markf (rson, 1); pushup (ahora); regreso; } int mid = (l + r) >> 1; if (L <= mid && R> mid) { actualizar (l, mid, lson, L, R); actualización (mid + 1, r, rson, L, R); } else if (L <= mid) { update (l, mid, lson, L, R); int p = rson; markf (p << 1,1), markf (p << 1 | 1,1); markg (p << 1,1), markg (p << 1 | 1,1); g [p] = (ll) (g [p] + g [p])% mod; flexión (p); } else { actualización (mid + 1, r, rson, L, R); int p = lson; pushdown (p); markf (p << 1,1), markf (p << 1 | 1,1); markg (p << 1,1), markg (p << 1 | 1,1); f [p] = (ll) (f [p] + qp [cur-1] -g [p] + mod)% mod; g [p] = (ll) (g [p] + g [p])% mod; flexión (p); } // 2 类 点 // g [ahora] = (ll) (g [ahora] + qp [cur-1])% mod; pushup (ahora); } int main () { // setIO ("input"); qp [0] = 1; para (int i = 1; i <N; ++ i) qp [i] = (ll) qp [i-1] * 2% mod; scanf ("% d% d", & n, & m); construir (1, n, 1); para (int i = 1; i <= m; ++ i) { int op, l, r; scanf ("% d", & op); if (op == 1) { scanf ("% d% d", & l, & r), ++ cur, update (1, n, 1, l, r); } else { printf ("% lld \ n", SUM [1]); } } devuelve 0; }