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

23670번 - Desperate Fire Survive 다국어

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

문제

Rikka is running with her every cell to the hall where the contest will be held.

Well, EC Final is growing bigger and bigger... Thus more and more computers have been connected into the weak 2000W main wires. Heat is accumulating in every row.

When Rikka enters the hall, she finds LCR there rearranging the wires with the volunteers. However, the girl might not be able to do anything helpful but observing.

"Listen. We have no time to calculate parameters for the new circuit. Are you good at data structures? Help us, please..."

The circuitry is a sequence of $n$ nodes, where there are $m$ possible levels of nodes in total, numbered from 1ドル$ to $m$. Since a $k$-level node has a power limit twice of a $(k-1)$-level one, Rikka could merge two adjacent $k$-level nodes into a $(k+1)$-level one if $k < m$. She can also remove any node at any time from the circuitry while the order of rest nodes remains.

The volunteers have $q$ queries in total. Each query contains a segment $[l,r]$ and an integer level $k$. Rikka needs to count how many sub-segments of the assigned segment (i.e. a segment $[x, y]$ such that $l\le x\le y\le r$) can provide a $k$-level node, which means it is possible to turn circuitry sequence $[x,y]$ into a single $k$-level node by merging adjacent nodes at the same level and removing nodes, where these two types of operations can be performed multiple times in any order. Notice that the level must be exactly $k$ rather than higher or lower.

입력

The first line contains three integers $n,m,q (1 \leq n,m,q \leq 2 \times 10^5),ドル the length of the circuitry sequence, the maximal level and the number of queries, respectively.

The second line contains $n$ integers $A_1, A_2, \dots, A_n (1 \leq A_i \leq m),ドル the levels of nodes in order.

Each of the following $q$ lines contains three integers $l,r,k (1 \leq l \leq r \leq n, 1 \leq k \leq m),ドル describing a query.

Multiple integers in the same line are separated by spaces.

출력

Output $q$ lines; each contains one integer, the answer to that query.

제한

예제 입력 1

5 5 5
1 1 1 1 1
1 5 1
1 5 2
1 5 3
1 5 4
1 5 5

예제 출력 1

15
10
3
0
0

예제 입력 2

5 5 5
4 3 2 1 1
1 5 1
1 5 2
1 5 3
1 5 4
1 5 5

예제 출력 2

9
10
9
6
1

힌트

출처

Contest > Open Cup > 2018/2019 Season > Stage 10: Grand Prix of Xi'An K번

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

출처

대학교 대회

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

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