XOR maximum-minimum matrices Solution Codechef 2021
SOLUTION
” CLICK HERE “
Chef has an integer matrix of rows and columns, and an integer .
A submatrix is defined as a rectangle of values inside . More formally, given two intervals and , the corresponding submatrix consists of the values such that and . Two submatrices are considered different if one of the ranges or differs.
Chef uses to denote the total number of submatrices in which
where denotes bitwise XOR, denotes the maximum integer in , and denotes the minimum integer in .
Chef does not know in which order he would like to put the rows. He wishes to know the value of for every permutation of rows, but since the amount of them can be too large, he wants to know the sum of the answers over all permutations.
Input
- The first line contains three space-separated integers , and .
- Next lines contains integers each: the -th integer of the -th line .
Output
Output the sum of over all permutations of the rows of .
Constraints
Sample Input
3 3 3
1 2 1
0 3 0
2 1 2
Sample Output
120

Social Plugin