QOJ.ac

QOJ

حد الوقت: 2.0 s حد الذاكرة: 128 MB مجموع النقاط: 140

#16366. ŠUMA

الإحصائيات

Mirko 住在有一片巨大的魔法森林里,那里的树木非常高,而且生长得非常快。这片森林可以用一个 $N \times N$ 的矩阵表示,每个单元格中都有一棵树。

Mirko 非常喜欢魔法森林里的树木。他花了很多年的时间观察它们,并测量了每棵树一年能长高多少米。树木是连续生长的。换句话说,如果一棵树一年长高 $5$ 米,那么它在半年内就会长高 $2.5$ 米。

除了树木,Mirko 还喜欢魔法森林里的蘑菇。有时,他会吃一些可疑的彩色蘑菇,然后开始思考一些奇特的问题。昨天,这种不幸的事情发生了,他想知道:如果树木继续以当前的生长速度生长,那么在未来的某个时刻(包括当前时刻),高度完全相同的最大连通树群的大小会是多少?

Mirko 迅速测量了森林中所有树木的当前高度,并请求你回答他的问题。

如果两棵树在矩阵中的单元格共享一条公共边,则称它们是相邻的。

如果存在一条由相邻树木组成的序列,从第一棵树通往第二棵树,则称这两棵树是连通的。

如果一个树群中的任意两棵树都是连通的,则称该树群是连通的。

输入格式

输入的第一行包含一个整数 $N$ ($1 \le N \le 700$)。

接下来 $N$ 行,每行包含 $N$ 个整数。 第 $i$ 行包含整数 $h_{ij}$ ($1 \le h_{ij} \le 10^6$),表示第 $i$ 行第 $j$ 列的树的初始高度,单位为米。

接下来 $N$ 行,每行包含 $N$ 个整数。 第 $i$ 行包含整数 $v_{ij}$ ($1 \le v_{ij} \le 10^6$),表示第 $i$ 行第 $j$ 列的树的生长速度,单位为米/年。

注意:由于输入数据量较大,请使用较快的输入方式(例如,在 C++ 中使用 scanf 代替 cin,或在 Java 中使用 BufferedReader 代替 Scanner)。

输出格式

输出的第一行也是唯一的一行,包含题目所求的答案。

数据范围

在占总分 30% 的测试数据中,满足 $1 \le N \le 70$。

样例

输入样例 1

3
1 2 3
3 2 2
5 2 1
3 2 1
1 2 1
1 2 3

输出样例 1

7

输入样例 2

2
3 1
3 3
2 5
2 5

输出样例 2

3

说明

第二个样例的解释:在 $8$ 个月(即 $\frac{2}{3}$ 年)后,位于 $(0, 0)$、$(0, 1)$ 和 $(1, 0)$ 的树的高度都将变为 $\frac{13}{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.