Jailing
시간 제한10초메모리 제한512 MB
격자에서 같은 값을 가진 칸들의 최소 경계 사각형을 구한 뒤, 각 사각형마다 다른 사각형과의 f 가중합을 계산해 자기 값과 XOR한 결과를 출력한다.
문제
Bobo has a matrix of size filled with integers. It is guaranteed that all cells which contain the same value are -side connected.
Let's define a jailing of a connected component with value as minimum-area rectangle (with sides parallel to the matrix sides) that covers all cells of the component.
For each jailing , Jessica would like to find the value of
where is the set of all integers in the matrix and
입력
The input consists of several test cases terminated by end-of-file. For each test case:
The first line contains two integers and -- the size of the matrix.
The second line contains integers , , , , where is the value in the -th row and the -th column.
출력
For each test case, output an integer denoting the value of , where denotes the exclusive-or (XOR) operator.
제한
- It is guaranteed that all cells which contain the same value are -side connected.
- It is guaranteed that the sum of in all test cases does not exceed .