#B4264. [GESP202503 四级] 二阶矩阵

[GESP202503 四级] 二阶矩阵

Cannot parse: bad indentation of a mapping entry (3:10) 1 | time: 1s 2 | memory: 131072 3 | - input: 1.in --------------^ 4 | output: 1.out 5 | - input: 2.in

题目背景

对应的选择、判断题:https://ti.luogu.com.cn/problemset/1176

题目描述

小 A 有一个 nn 行 mm 列的矩阵 AA。

小 A 认为一个 2×22 \times 2 的矩阵 DD 是好的,当且仅当 D1,1×D2,2=D1,2×D2,1D_{1,1} \times D_{2,2} = D_{1,2} \times D_{2,1}。其中 Di,jD_{i,j} 表示矩阵 DD 的第 ii 行第 jj 列的元素。

小 A 想知道 AA 中有多少个好的子矩阵。

输入格式

第一行,两个正整数 n,mn, m。

接下来 nn 行,每行 mm 个整数 Ai,1,Ai,2,…,Ai,mA_{i,1}, A_{i,2}, \ldots, A_{i,m}。

输出格式

一行,一个整数,表示 AA 中好的子矩阵的数量。

输入输出样例 #1

输入 #1

3 4
1 2 1 0
2 4 2 1
0 3 3 0

输出 #1

2

说明/提示

样例解释

样例中好的子矩阵如下:

数据范围

对于所有测试点,保证 1≤n≤5001\leq n\leq 500,1≤m≤5001\leq m\leq 500,−100≤Ai,j≤100-100\leq A_{i,j}\leq 100