#P10516. 数据结构

    ID: 11707 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>线段树洛谷原创O2优化洛谷月赛

数据结构

Background

Little M likes data structures very much. Unfortunately, he did not make it into the NOI Qualifier team.

Everyone has dreams, and everyone has their own wonderful life.

Problem Description

Given two sequences aia_i and bib_i of length nn. There are three types of operations:

  1. Given an interval [l,r][l,r] and parameters k,tk,t, for each position in the interval that satisfies ai×bika_i\times b_i\leq k, add tt to aia_i and add tt to bib_i.
  2. Given ii and x,yx,y, set aia_i to xx, and set bib_i to yy.
  3. Query the sum of ai+bia_i+b_i over all positions in the interval.

Input Format

The first line contains two integers n,mn,m, representing the number of elements in the sequences and the total number of operations.

The second line contains nn integers separated by spaces; the ii-th integer is aia_i.

The third line contains nn integers separated by spaces; the ii-th integer is bib_i.

The next mm lines each contain 33 to 55 integers, describing one operation as follows:

  1. 1 l r k t: perform Operation 1 on interval [l,r][l,r].
  2. 2 i x y: set aia_i to xx, and set bib_i to yy.
  3. 3 l r: output the sum over the interval [l,r][l,r].

Output Format

Output several lines, each being the answer to an Operation 3 query.

5 5
23 4 3 3 7
54 29 7 1 2
1 1 5 114 1
2 2 7 9
3 1 5
3 1 2
3 3 4
122
93
18

Hint

[Sample Explanation]

After the first modification, the sequence aia_i is: {23,4,4,4,8}\left\{23,4,4,4,8\right\}; the sequence bib_i is {54,29,8,2,3}\left\{54,29,8,2,3\right\}.

After the second modification, the sequence aia_i is: {23,7,4,4,8}\left\{23,7,4,4,8\right\}; the sequence bib_i is {54,9,8,2,3}\left\{54,9,8,2,3\right\}.

[Constraints]

  • For 5%5\% of the testdata, n,m5n,m\le 5.
  • For 10%10\% of the testdata, n,m100n,m\leq 100.
  • For 25%25\% of the testdata, n,m5000n,m\leq 5000.
  • For another 5%5\% of the testdata, there are no Operations 1 and 2.
  • For another 10%10\% of the testdata, there is no Operation 1.
  • For another 20%20\% of the testdata, there is no Operation 2.

For all testdata, 1n,m1051\leq n,m\leq 10^5, 0ai,bi,k,t,x,y1050\leq a_i,b_i,k,t,x,y\leq10^5.

Translated by ChatGPT 5