307818: CF1422B. Nice Matrix
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Nice Matrix
题意翻译
给你一个 $n*m$ 的矩阵,你可以每次将其中一个数 $+1$ 或 $-1$ ,求多少次可以使矩阵每一行每一列为回文的. 若一个数列 $(a_1,a_2,a_3,\dots,a_n)$ 为回文, $\forall a_i ,a_i = a_{n-i+1}$ $\texttt{Data Range:}$ $1 \leq n,m \leq 100,a_i \leq 10^9$题目描述
A matrix of size $ n \times m $ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $ (a_1, a_2, \dots , a_k) $ is a palindrome, if for any integer $ i $ ( $ 1 \le i \le k $ ) the equality $ a_i = a_{k - i + 1} $ holds. Sasha owns a matrix $ a $ of size $ n \times m $ . In one operation he can increase or decrease any number in the matrix by one. Sasha wants to make the matrix nice. He is interested what is the minimum number of operations he needs. Help him!输入输出格式
输入格式
The first line contains a single integer $ t $ — the number of test cases ( $ 1 \le t \le 10 $ ). The $ t $ tests follow. The first line of each test contains two integers $ n $ and $ m $ ( $ 1 \le n, m \le 100 $ ) — the size of the matrix. Each of the next $ n $ lines contains $ m $ integers $ a_{i, j} $ ( $ 0 \le a_{i, j} \le 10^9 $ ) — the elements of the matrix.
输出格式
For each test output the smallest number of operations required to make the matrix nice.
输入输出样例
输入样例 #1
2
4 2
4 2
2 4
4 2
2 4
3 4
1 2 3 4
5 6 7 8
9 10 11 18
输出样例 #1
8
42