Road
by Matteo Paganelli, Unsplash
Vegagerðin is renewing the software they use to track
maintenance and repair costs for roads. The first step towards
that is implementing the new system for the most important road
in the country, hringvegurinn. To simplify things, the circular
road is divided into
equally long sections and they are numbered
where
is the road heading west from
Akureyri and the sections are in increasing order following
that one going around the country. Then section
is the section of road east of
Akureyri. The system needs to support the following operations.
It needs to be possible to register a cost
for each section in an interval.
It needs to be possible to get the total cost for an interval
thus far. Finally the system has to be able to rotate the
numbering such that section
is in a new location. An interval
means a contigious section of the road. The interval
contains the
sections
.
However, if
the
interval
contains
the sections
.
The interval
is
just the section
.
After relabeling the sections the orientation is still the
same, so the sections are still increasing when traveling
counter-clockwise. Rotating by
section means that the section
numbered
will be
numbered
and section
numbered
will be
numbered
.
Input
The first line of the input contains two integers, the
number of sections and
the number of queries
(,
).
Next there are lines,
each with one query. Each query is a single line and starts
with the number or
. If it starts with
there will follow a
single number
() which
means the numbering should be rotated cyclically by
sections
counter-clockwise. If the query starts with the number
there will follow
three integers
(,
)
which means that the total cost on the sections from
to should each be increased by
. Finally if the query
starts with the number
there will follow two integers () in which case
the total cost of the sections from to should be printed.
Output
One line for each query starting with the number
should be printed as
described above.
Scoring
Group
|
Points
|
Constraints
|
1
|
20
|
|
2
|
50
|
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
|