Codeforces Round 198 (Div. 1)
D
Iahub and Xors
Codeforces
2500
原题
← CE →
翻译中…

Iahub does not like background stories, so he'll tell you exactly what this problem asks you for.

翻译中…

You are given a matrix $*a*$ with $*n*$ rows and $*n*$ columns. Initially, all values of the matrix are zeros. Both rows and columns are 1-based, that is rows are numbered 1, 2, ..., $*n*$ and columns are numbered 1, 2, ..., $*n*$. Let's denote an element on the $*i*$-th row and $*j*$-th column as $*a*_{*i*, *j*}$.

翻译中…

We will call a submatrix $(*x*_{0}, *y*_{0}, *x*_{1}, *y*_{1})$ such elements $*a*_{*i*, *j*}$ for which two inequalities hold: $*x*_{0} ≤ *i* ≤ *x*_{1}$, $*y*_{0} ≤ *j* ≤ *y*_{1}$.

翻译中…

Write a program to perform two following operations:

翻译中…
  1. Query($*x*_{0}$, $*y*_{0}$, $*x*_{1}$, $*y*_{1}$): print the xor sum of the elements of the submatrix $(*x*_{0}, *y*_{0}, *x*_{1}, *y*_{1})$.
  2. Update($*x*_{0}$, $*y*_{0}$, $*x*_{1}$, $*y*_{1}$, $*v*$): each element from submatrix $(*x*_{0}, *y*_{0}, *x*_{1}, *y*_{1})$ gets xor-ed by value $*v*$.
翻译中…

Input

翻译中…

The first line contains two integers: $*n*$ ($1 ≤ *n* ≤ 1000$) and $*m*$ ($1 ≤ *m* ≤ 10^{5}$). The number $*m*$ represents the number of operations you need to perform. Each of the next $*m*$ lines contains five or six integers, depending on operation type.

翻译中…

If the $*i*$-th operation from the input is a query, the first number from $*i*$-th line will be 1. It will be followed by four integers $*x*_{0}$, $*y*_{0}$, $*x*_{1}$, $*y*_{1}$. If the $*i*$-th operation is an update, the first number from the $*i*$-th line will be 2. It will be followed by five integers $*x*_{0}$, $*y*_{0}$, $*x*_{1}$, $*y*_{1}$, $*v*$.

翻译中…

It is guaranteed that for each update operation, the following inequality holds: $0 ≤ *v* < 2^{62}$. It is guaranteed that for each operation, the following inequalities hold: $1 ≤ *x*_{0} ≤ *x*_{1} ≤ *n*$, $1 ≤ *y*_{0} ≤ *y*_{1} ≤ *n*$.

翻译中…

Output

翻译中…

For each query operation, output on a new line the result.

翻译中…

Note

翻译中…

After the first $3$ operations, the matrix will look like this:

翻译中…

1 1 2
1 1 2
3 3 3

翻译中…

The fourth operation asks us to compute 1 xor 2 xor 3 xor 3 = 3.

翻译中…

The fifth operation asks us to compute 1 xor 3 = 2.

翻译中…

样例

Input #1
3 5
2 1 1 2 2 1
2 1 3 2 3 2
2 3 1 3 3 3
1 2 2 3 3
1 2 2 3 2
Output #1
3
2
InputCopy OutputCopy
题目信息
题号
341D
时间限制
1 s
内存限制
256 MB
标签
数据结构

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。