Problem B
Hringvegurinn
Languages
en
is
Input
The first line of the input contains two integers, the number of sections $N$ and the number of queries $q$ ($1 \leq N \leq 10^6$, $1 \leq q \leq 10^4$). Next there are $q$ lines, each with one query. Each query is a single line and starts with the number $1, 2$ or $3$. If it starts with $1$ there will follow a single number $t$ ($1 \leq t \leq N$) which means the numbering should be rotated cyclically by $t$ sections counter-clockwise. If the query starts with the number $2$ there will follow three integers $l, r, x$ ($1 \leq l, r \leq N$, $1 \leq x \leq 10^9$) which means that the total cost on the sections from $l$ to $r$ should each be increased by $x$. Finally if the query starts with the number $3$ there will follow two integers $l, r$ ($1 \leq l, r \leq N$) in which case the total cost of the sections from $l$ to $r$ should be printed.
Output
One line for each query starting with the number $3$ should be printed as described above.
Scoring
Group |
Points |
Constraints |
1 |
20 |
$1 \leq n \leq 1000$ |
2 |
50 |
$l \leq r$ in all intervals and there are no rotation operations |
3 |
30 |
No further constraints |
Sample Input 1 | Sample Output 1 |
---|---|
10 10 2 2 4 3 2 3 3 4 3 3 4 3 4 2 1 1 2 4 1 7 3 1 3 1 5 3 10 1 3 2 2 |
10 6 20 14 7 |