{"trustable":false,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"MD","content":"\u003cscript type\u003d\u0027text/x-mathjax-config\u0027\u003eMathJax.Hub.Config({tex2jax: { inlineMath: [[\u0027$\u0027,\u0027$\u0027]] } }); \u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027 src\u003d\u0027https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\u0027\u003e\u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027\u003esetTimeout(function(){MathJax.Hub.Queue([\u0027Typeset\u0027, MathJax.Hub, \u0027left_view\u0027]);}, 2000);\u003c/script\u003e\n\u003cdiv class\u003d\"panel_content\"\u003e \n \u003cstrong\u003eBackground\u003c/strong\u003e \n \u003cbr\u003eTo The Moon is a independent game released in November 2011, it is a role-playing adventure game powered by RPG Maker. \n \u003cbr\u003eThe premise of To The Moon is based around a technology that allows us to permanently reconstruct the memory on dying man. In this problem, we\u0027ll give you a chance, to implement the logic behind the scene. \n \u003cbr\u003e \n \u003cbr\u003eYou‘ve been given N integers A \n \u003csub\u003e[1]\u003c/sub\u003e, A \n \u003csub\u003e[2]\u003c/sub\u003e,..., A \n \u003csub\u003e[N]\u003c/sub\u003e. On these integers, you need to implement the following operations: \n \u003cbr\u003e \n \u003cstrong\u003e1.\u003c/strong\u003e C l r d: Adding a constant d for every {A \n \u003csub\u003ei\u003c/sub\u003e | l \u0026lt;\u003d i \u0026lt;\u003d r}, and increase the time stamp by 1, this is the only operation that will cause the time stamp increase. \n \u003cbr\u003e \n \u003cstrong\u003e2.\u003c/strong\u003e Q l r: Querying the current sum of {A \n \u003csub\u003ei\u003c/sub\u003e | l \u0026lt;\u003d i \u0026lt;\u003d r}. \n \u003cbr\u003e \n \u003cstrong\u003e3.\u003c/strong\u003e H l r t: Querying a history sum of {A \n \u003csub\u003ei\u003c/sub\u003e | l \u0026lt;\u003d i \u0026lt;\u003d r} in time t. \n \u003cbr\u003e \n \u003cstrong\u003e4.\u003c/strong\u003e B t: Back to time t. And once you decide return to a past, you can never be access to a forward edition anymore. \n \u003cbr\u003e .. N, M ≤ 10 \n \u003csup\u003e5\u003c/sup\u003e, |A \n \u003csub\u003e[i]\u003c/sub\u003e| ≤ 10 \n \u003csup\u003e9\u003c/sup\u003e, 1 ≤ l ≤ r ≤ N, |d| ≤ 10 \n \u003csup\u003e4\u003c/sup\u003e .. the system start from time 0, and the first modification is in time 1, t ≥ 0, and won\u0027t introduce you to a future state. \n\u003c/div\u003e\n一个长度为n的数组,4种操作 :\n\n (1)C l r d:区间[l,r]中的数都加1,同时当前的时间戳加1 。\n\n (2)Q l r:查询当前时间戳区间[l,r]中所有数的和 。\n\n (3)H l r t:查询时间戳t区间[l,r]的和 。\n\n (4)B t:将当前时间戳置为t 。回到过去t时刻,t之后的信息都会消失,即就不会再向前跳跃。\n\n 所有操作均合法 。"}},{"title":"Input","value":{"format":"MD","content":"n m \n\u003cbr\u003eA \n\u003csub\u003e1\u003c/sub\u003e A \n\u003csub\u003e2\u003c/sub\u003e ... A \n\u003csub\u003en\u003c/sub\u003e \n\u003cbr\u003e... (here following the m operations. )"}},{"title":"Output","value":{"format":"MD","content":"... (for each query, simply print the result. )"}},{"title":"Sample Input","value":{"format":"MD","content":"\u003cpre\u003e10 5\n1 2 3 4 5 6 7 8 9 10\nQ 4 4\nQ 1 10\nQ 2 4\nC 3 6 3\nQ 2 4\n\n2 4\n0 0\nC 1 1 1\nC 2 2 -1\nQ 1 2\nH 1 2 1\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"MD","content":"\u003cpre\u003e4\n55\n9\n15\n\n0\n1\u003c/pre\u003e"}}]}