时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld
题目描述
Xay has two sequences

and

.
Given an interval [l,r], Xay will choose a subset of positions in the following way:
- Add l into the set.
- Let s be the biggest position currently in the set. Find the smallest i>s so that
. - If there is no such i or i>r, end the procedure. Otherwise add i into the set and go to step 2.
Let

be the set xay chose sorted in increasing order. He defines the roughness of the set to be the number of adjacent positions in it so that

.
He wants to know the roughness of hypothetical sets that he is likely to choose. Can you answer it?
Sometimes Xay will also change some values in a and b.
输入描述:
The first line contains an integer n(

).
The next line contains n integers

(

).
The next line contains n integers

(

).
The next line contains an interger q(

).
Then q line follows. Each line contains three integers opt,t1,t2(

).
If opt=1, Xay changes

to t2(

).
If opt=2, Xay adds

by 1 for each

(

).
If opt=3, Xay imagine he chose a set when given [t1,t2], and wants to know the roughness of this hypothetical set(

).
输出描述:
For every query such that opt=3, output one line indicating the answer.
示例1
输入
复制
5
1 3 2 4 5
0 1 0 1 0
5
3 2 4
1 5 3
3 1 5
2 3 5
3 1 5