#P4964. Propagation Exam Broadcasting
Propagation Exam Broadcasting
Propagation Exam Broadcasting
There is a special exam where n students are seated in a row, numbered from 1 to n. Among them, the student at position c (initially with ability wc) can update his ability. Each student i has an ability wi and is assigned a walkie‐talkie with a fixed reception range di.
The exam works as follows. When a problem with difficulty x is released, every student who can solve it directly is determined by checking whether
and these students immediately broadcast their solution. In addition, any student i will also solve the problem if i can receive the broadcast from any student j within his own receiving range, i.e. if there exists some j in the interval
such that student j has solved the problem. When a student solves the problem (either directly because wi is sufficient or indirectly via broadcast), he also broadcasts his solution. This process repeats until no additional student can be activated.
You are given two types of operations:
- 1 x: Query the final number of students who will solve a problem of difficulty x after all possible broadcasts. Formally, define for each student i a value $$f_i=\begin{cases}1 & \text{if } w_i\ge x,\\[5mm]1 & \text{if there exists } j\in [i-d_i,i+d_i] \text{ with } f_j=1,\\[3mm]0 & \text{otherwise.}\end{cases}$$
- 2 x: Update the ability of student c by setting wc to x.
Your task is to process m operations. For each query operation (type 1), output the total number of students that eventually solve the problem.
## inputFormatThe first line contains three integers n, m, and c (1 ≤ c ≤ n) — the number of students, the number of operations, and the index of the student whose ability can be updated.
The second line contains n integers representing the abilities w1, w2, ... , wn.
The third line contains n integers representing the reception ranges d1, d2, ... , dn.
The following m lines each describe an operation in one of the following two formats:
1 x
: Query operation for a problem with difficulty x.2 x
: Update operation that sets wc to x.
For each query operation (lines beginning with 1), output a single integer on a new line — the number of students who will eventually solve the problem.
## sample5 5 3
3 1 2 4 1
1 0 2 1 1
1 2
2 5
1 4
1 3
1 1
4
3
4
5
$$