#P2846. [USACO08NOV] Light Switching G

[USACO08NOV] Light Switching G

题目描述

Farmer John tries to keep the cows sharp by letting them play with intellectual toys. One of the larger toys is the lights in the barn. Each of the N(2N105)N (2 \le N \le 10^5) cow stalls conveniently numbered 1N1\ldots N has a colorful light above it.

At the beginning of the evening, all the lights are off. The cows control the lights with a set of N pushbutton switches that toggle the lights; pushing switch i changes the state of light i from off to on or from on to off.

The cows read and execute a list of M(1M105)M(1\le M \le 10^5) operations expressed as one of two integers ( 00 \le operation 1\le 1 ).

The first kind of operation (denoted by a 00 command) includes two subsequent integers SiS_i and Ei(1SiEiN)E_i (1 \le S_i \le E_i \le N) that indicate a starting switch and ending switch. They execute the operation by pushing each pushbutton from SiS_i through EiE_i inclusive exactly once.

The second kind of operation (denoted by a 11 command) asks the cows to count how many lights are on in the range given by two integers SiS_i and Ei(1SiEiN)E_i (1 \le S_i \le E_i \le N) which specify the inclusive range in which the cows should count the number of lights that are on.

Help FJ ensure the cows are getting the correct answer by processing the list and producing the proper counts.

输入格式

11 行: 用空格隔开的两个整数 NNMMNN 是灯数,MM是指令数。

2M+12\ldots M+1 行: 每行表示一个操作, 有三个用空格分开的整数: 指令号, SiS_iEiE_i

输入

4 5
0 1 2
0 2 4
1 2 3
0 2 4
1 1 4

输出

1
2

提示

数据点编号 NN MM
121\sim 2 100\le 100
343\sim 4 1000\le 1000
565\sim 6 10000\le 10000
787\sim 8 105\le 10^5 100\le 100
9109\sim 10 100\le 100 105\le 10^5
111211\sim 12 1000\le 1000
131413\sim 14 105\le 10^5 1000\le 1000
151615\sim 16 10000\le 10000
171817\sim 18 10\le 10 105\le 10^5
192019\sim 20 2000\le 2000 106\le 10^6