luogu#P5057. [CQOI2006] 简单题

    ID: 4064 远端评测题 1000ms 500MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>2006重庆线段树各省省选树状数组

[CQOI2006] 简单题

Problem Description

There is an array with nn elements, and each element is initially 00. There are mm instructions, and each instruction is one of the following two operations:

  1. Flip all numbers in a continuous segment. (That is, 00 becomes 11, and 11 becomes 00.)
  2. Query the value of a certain element.

For example, when n=20n=20, the 1010 instructions are as follows:

Input Format

The first line contains two integers n,mn, m, representing the length of the array and the number of instructions.

In the next mm lines, the first number is tt, representing the type of operation:

  • If t=1t = 1, then two numbers L,RL, R follow, meaning to flip every number in the interval [L,R][L, R].
  • If t=2t = 2, then only one number ii follows, meaning to query the index.

Output Format

For each operation 22, output one line (either 00 or 11), representing the answer to that query.

20 10
1 1 10
2 6
2 12
1 5 12
2 6
2 15
1 6 16
1 11 17
2 12
2 6
1
0
0
0
1
1

Hint

For 50%50\% of the testdata, 1n1031 \le n \le 10^3, 1m1041 \le m \le 10^4.

For 100%100\% of the testdata, 1n1051 \le n \le 10^5, 1m5×1051 \le m \le 5 \times 10^5, and it is guaranteed that LRL \le R.

Translated by ChatGPT 5