classSolution: defchangeCount(self, m, n, nums): ans = 0 m, n = m - 1, n - 1 m_m, n_m = m // 2, n // 2 i = 0 while (i <= m_m): j = 0 while (j <= n_m): # print([nums[i][j], nums[m - i][j], nums[i][n - j], nums[m - i][n - j]]) a = collections.Counter([nums[i][j], nums[m - i][j], nums[i][n - j], nums[m - i][n - j]]) # print(a) # print(max(a.values())) if (m % 2 == 0and i == m // 2) or (n % 2 == 0and j == n // 2): # 说明为奇数且目前在中间一列 iflen(a) == 2: ans += 1 else: ans += 4 - max(a.values()) j += 1 i += 1 return ans
if __name__ == '__main__': s = Solution() # 输入输出格式 # shape = [eval(i) for i in input().split(' ')] # m, n = shape[0], shape[1] # # print(m, n) # array = [[0] * n for _ in range(m)] # for i in range(m): # array[i] = [eval(j) for j in input().split(' ')]