[GESP202503 四级] 二阶矩阵

Luogu
IDLGB4264
Time1000ms
Memory512MB
DifficultyP1
2025枚举GESP
小 A 有一个 $n$ 行 $m$ 列的矩阵 $A$。 小 A 认为一个 $2 \times 2$ 的矩阵 $D$ 是好的,当且仅当 $D_{1,1} \times D_{2,2} = D_{1,2} \times D_{2,1}$。其中 $D_{i,j}$ 表示矩阵 $D$ 的第 $i$ 行第 $j$ 列的元素。 小 A 想知道 $A$ 中有多少个好的子矩阵。 ## Input 第一行,两个正整数 $n, m$。 接下来 $n$ 行,每行 $m$ 个整数 $A_{i,1}, A_{i,2}, \ldots, A_{i,m}$。 ## Output 一行,一个整数,表示 $A$ 中好的子矩阵的数量。 [samples] ## Background 对应的选择、判断题:<https://ti.luogu.com.cn/problemset/1176> ## Note ### 样例解释 样例中好的子矩阵如下: ![](https://cdn.luogu.com.cn/upload/image_hosting/lcdtefnp.png) ### 数据范围 对于所有测试点,保证 $1\leq n\leq 500$,$1\leq m\leq 500$,$-100\leq A_{i,j}\leq 100$
Samples
Input #1
3 4
1 2 1 0
2 4 2 1
0 3 3 0
Output #1
2
API Response (JSON)
{
  "problem": {
    "name": "[GESP202503 四级] 二阶矩阵",
    "description": {
      "content": "小 A 有一个 $n$ 行 $m$ 列的矩阵 $A$。 小 A 认为一个 $2 \\times 2$ 的矩阵 $D$ 是好的,当且仅当 $D_{1,1} \\times D_{2,2} = D_{1,2} \\times D_{2,1}$。其中 $D_{i,j}$ 表示矩阵 $D$ 的第 $i$ 行第 $j$ 列的元素。 小 A 想知道 $A$ 中有多少个好的子矩阵。",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 524288
    },
    "difficulty": {
      "LuoguStyle": "P1"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGB4264"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "小 A 有一个 $n$ 行 $m$ 列的矩阵 $A$。\n\n小 A 认为一个 $2 \\times 2$ 的矩阵 $D$ 是好的,当且仅当 $D_{1,1} \\times D_{2,2} = D_{1,2} \\times D_{2,1}$。其中 $D_{i,j}$ 表示矩阵 $D$ 的第 $i$ 行第 $j$ 列的元素。\n\n小 A 想知道 $A$ 中有多少个好的子矩阵。\n\n## Input\n\n第一行,...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments