QOJ.ac

QOJ

Limite de temps : 1.5 s Limite de mémoire : 256 MB Points totaux : 100 Hackable ✓

#6373. 打动她

Statistiques

Zenyk 决定给 Marichka 留下深刻印象,并解决了下面这个有趣的问题。

给定一个大小为 $n \times m$ 的整数矩阵。保证所有包含相同数值的单元格都是 4-连通的。

我们将一个连通分量的凸包定义为覆盖该分量所有单元格的最小面积矩形(其边与矩阵的边平行)。任务是计算满足分量 $a$ 的凸包在分量 $b$ 的凸包内部的有序对 $(a, b)$ 的数量。请注意,凸包的边可以接触。

输入格式

第一行包含一对整数 $n$ 和 $m$ ($1 \le n, m \le 500$),表示矩阵的行数和列数。接下来的 $n$ 行,每行包含 $m$ 个整数,表示该矩阵。保证矩阵中的整数是非负的且不超过 $10^6$。

输出格式

仅输出一行,包含一个整数,即问题的答案。

样例

输入 1

3 4
1 2 2 4
1 1 1 4
5 1 7 4

输出 1

3

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.