#P5066. [Ynoi Easy Round 2014] 人人本着正义之名

[Ynoi Easy Round 2014] 人人本着正义之名

Description

You need to help Chtholly maintain a 01 sequence aa of length nn. There are mm operations:

  • 1 l r: Set all numbers in interval [l,r][l,r] to 00.
  • 2 l r: Set all numbers in interval [l,r][l,r] to 11.
  • 3 l r: For all aia_i in [l,r1][l,r-1], change it to the bitwise OR of aia_i and ai+1a_{i+1}. These changes are performed simultaneously.
  • 4 l r: For all aia_i in [l+1,r][l+1,r], change it to the bitwise OR of aia_i and ai1a_{i-1}. These changes are performed simultaneously.
  • 5 l r: For all aia_i in [l,r1][l,r-1], change it to the bitwise AND of aia_i and ai+1a_{i+1}. These changes are performed simultaneously.
  • 6 l r: For all aia_i in [l+1,r][l+1,r], change it to the bitwise AND of aia_i and ai1a_{i-1}. These changes are performed simultaneously.
  • 7 l r: Query the sum over interval [l,r][l,r].

This problem is forced online. Each l,rl,r needs to be XORed with the previous answer using xor\operatorname{xor}. If there has been no query before, then the previous answer is 00.

Input Format

The first line contains two integers nn and mm.

The second line contains nn integers representing the sequence aa.

Then follow mm lines, each containing three integers opt,l,ropt,l,r, indicating which operation it is and the interval it applies to.

Output Format

For each query operation, output one line with one number as the answer.

5 5
0 1 0 0 1
3 2 5
5 2 5
2 2 2
6 1 5
7 1 5
1

Hint

Idea: nzhtl1477, Solution: nzhtl1477, Code: nzhtl1477, Data: nzhtl1477.

The sequence after each step:

0 1 0 0 10\ 1\ 0\ 0\ 1 0 1 0 1 10\ 1\ 0\ 1\ 1 0 0 0 1 10\ 0\ 0\ 1\ 1 0 1 0 1 10\ 1\ 0\ 1\ 1 0 0 0 0 10\ 0\ 0\ 0\ 1 0 0 0 0 10\ 0\ 0\ 0\ 1

For 30%30\% of the testdata, n,m1000n,m\leq 1000.

For 50%50\% of the testdata, n,m105n,m\leq 10^5.

For another 30%30\% of the testdata, both the operations and the sequence are generated randomly.

For another 10%10\% of the testdata, n,m106n,m\leq 10^6.

Constraints: for 100%100\% of the testdata, 1n,m3×1061\leq n,m\leq 3 \times 10^6, 0ai10\leq a_i\leq 1.

Translated by ChatGPT 5