Logo
(追記) (追記ここまで)

23605번 - Road 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 (추가 시간 없음) 512 MB633100.000%

문제

Johnny became a controller at the Road Center. His task is to investigate the effectiveness of snow removal on a certain road during a series of blizzards. The road is divided into consecutive one kilometer-long segments, numbered with consecutive integers from 1ドル$ to $n$. Johnny quickly got to work and gathered the information on events:

  • Meteorological Center provided him with information about the blizzards; the intensity of a blizzard is determined by two parameters $f, g$: in $i$-th minute ($i \ge 1$) of such a blizzard $f \cdot i + g$ millimeters of snow fall everywhere on the road. Each blizzard ends in the minute preceding the first minute of the next blizzard. The time is calibrated so that the first blizzard begins at a positive minute, and in minute 0ドル$ there is no snow on the road.
  • Snow Removal Center provided Johnny with information about the plows and sanders. Each route of a plow or a sander is always a fragment of a road consisting of road segments numbered with consecutive numbers. If a plow clears some road segments in $t$-th minute then at the end of $t$-th minute there is no snow on the cleared road segments. Likewise, spreading salt of quality $s$ on some road segments in $t$-th minute ensures that at the end of minutes $ t, t + 1, \ldots, t + s $ there is no snow on those road segments. Different salts, even of the same quality, act independently and have no effect on each other; likewise, plows do not remove salt from the road.
  • Road Center has sent its queries -- give the thickness in millimeters of the largest snow cover at the end of a given minute at the given fragment of a road consisting of segments numbered with consecutive numbers.

Johnny pre-processed and sorted the collected data. Unfortunately, computing the answer to queries is too difficult for him. Help him! Write a program that computes the answers to queries of the Road Center.

입력

The first line of the input contains two integers $n$ and $q$ ($ 1 \le n \le 10^9, 1 \le q \le 300,000円$) separated by a single space and denoting, respectively, the number of kilometer segments of the road and the number of events. In each of the following $q$ lines there is a description of an event of one of the following four types:

  • t L a b, which means that the plow cleared in $t$-th minute a road fragment consisting of segments numbered from $a$ to $b$.
  • t S a b s, meaning that a sander spreads salt of quality $s$ in $t$-th minute on a road fragment consisting of segments
  • numbered from $a$ to $b$.
  • t ? a b, meaning that the Road Center wants to know
  • the maximum thickness of snow cover at the end of $t$-th minute on a road fragment consisting of segments numbered from $a$ to $b$.
  • t B f g, meaning that $t$-th minute is the last minute of the previous blizzard (if it exists), and $(t+1)$-th minute is the first minute of the blizzard with intensity $ f, g $.

In all events the following conditions are met: $ 1 \le t \le 10^9, 1 \le a \le b \le n, 1 \le s, f, g \le 10^9$.

In addition, the values of $t$ for consecutive events are increasing, and the first event is always of type B.

출력

For each event ? print in a separate line the remainder modulo 10ドル^9+7$ of the largest thickness of snow cover at the end of the given minute at the specified road segment.

제한

예제 입력 1

3 4
2 B 1 2
3 ? 2 2
4 L 1 3
5 ? 1 3

예제 출력 1

3
5

The table below shows the snow coverage on each of the road segment in Sample 1 at the end of each minute. It also shows the amount of snow that fell in each minute. The numbers in bold correspond to queries.

minute 1 2 3 snowfall
0 0 0 0 0
1 0 0 0 0
2 0 0 0 0
3 3 3 3 3
4 0 0 0 4
5 5 5 5 5

Till the first query 1ドル \cdot 1 + 2 = 3$ milimeters of snow fell on the whole road. Between the plow passage in minute 4ドル$ and the second \texttt{?} query additional 3ドル \cdot 1+2=5$ milimeters of snow fell.

예제 입력 2

1 3
1 B 1 1
2 B 3 3
3 ? 1 1

예제 출력 2

8
minute 1 snowfall
0 0 0
1 0 0
2 2 2
3 8 6

Till the ? event the first blizzard took place for one minute and the second also took place for one minute.

예제 입력 3

5 5
1 B 1 2
2 S 1 3 5
3 ? 3 4
4 ? 1 1
10 ? 1 1

예제 출력 3

7
0
30
minute 1 2 3 4 5 snowfall
0 0 0 0 0 0 0
1 0 0 0 0 0 0
2 0 0 0 3 3 3
3 0 0 0 7 7 4
4 0 0 0 12 12 5
5 0 0 0 18 18 6
6 0 0 0 25 25 7
7 0 0 0 33 33 8
8 9 9 9 42 42 9
9 19 19 19 52 52 10
10 30 30 30 63 63 11

힌트

출처

Contest > Open Cup > 2018/2019 Season > Stage 6: Grand Prix of Poland D번

ICPC > Regionals > Europe > Central European Regional Contest > Poland Collegiate Programming Contest > AMPPZ 2018 D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /