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

11843번 - Monkey and Apple-trees 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 256 MB173663934.211%

문제

Everyone knows that the yummiest fruit in the world is an apple. Even the monkey Chris knows that. There are many apple-trees in the a forest located along the river and numerated consecutively starting from 1. Sometimes Chris comes to the forest, chooses a group of apple-trees growing consecutively (selected interval) and counts the amount of apple-trees with red-ripen apples among them. Sometimes apples on a few consecutive apple-trees have red-ripen before his next arrival.

You have to answer how many apple-trees in the selected interval have red-ripen apples at each Chris's arrival. At the beginning all the apples are unripen

입력

In the first line of input file an integer M is given - number of events (1 ≤ M ≤ 100000). The following M lines contain description of events - each contains three integers Di, Xi, Yi (1 ≤ Di ≤ 2, Xi ≤ Yi). If the Di = 1, then the event is Chris's arrival, if the Di = 2 - red-ripening of all apples in the selected interval of the apple-trees. Other two numbers Xi and Yi, describe the interval for the event.

For calculating the limits of the interval there is an additional number C. At the beginning C = 0. An interval for the event is interval from Xi+C to Yi+C inclusively. It's guaranteed that 1 ≤ Xi+C, Yi+C ≤ 109.

If the event is apples red-ripening then C doesn't change. If the event is Chris's arrival, then as the result C becomes equal to the amount of red-ripen apple-trees he has counted.

출력

For each of Chris's arrival output one line with one number in it - the task answer.

제한

예제 입력 1

3
2 5 8
2 7 10
1 1 10

예제 출력 1

6

예제 입력 2

4
2 2 3
1 1 3
2 2 3
1 -1 3

예제 출력 2

2
4

예제 입력 3

6
2 1 7
2 10 12
1 7 11
2 11 13
1 8 10
1 15 17

예제 출력 3

3
2
0

힌트

출처

Olympiad > International Zhautykov Olympiad > IZhO 2012 F번

  • 문제의 오타를 찾은 사람: yclock
(追記) (追記ここまで)

출처

대학교 대회

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

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