QOJ.ac

QOJ

時間限制: 2 s - 3 s 記憶體限制: 1024 MB 總分: 28

#5802. 股票图表

统计

你正在撰写报纸的年度经济总结,并决定展示一系列图表来演示不同股票在过去一年中的表现。你已经决定展示 $n$ 种不同股票在一年中相同 $k$ 个时间点的价格。

某只股票的简单图表会连接点 $(0, \text{price}_0), (1, \text{price}_1), \dots, (k-1, \text{price}_{k-1})$,其中 $\text{price}_i$ 是该股票在第 $i$ 个时间点的价格。

为了节省空间,你发明了叠加图表的概念。叠加图表是一个或多个简单图表的组合,用于展示多只股票的价格(为每只股票绘制一条线)。为了避免图表中展示的股票之间产生混淆,叠加图表中的线条不得交叉或接触。

给定 $n$ 只股票在 $k$ 个时间点上的价格列表,确定展示所有股票价格所需的最少叠加图表数量。

输入格式

输入的第一行包含一个整数 $T$,表示测试用例的数量。接下来是 $T$ 个测试用例,每个测试用例的格式如下:

n k
price_{0,0} price_{0,1} ... price_{0,k-1}
price_{1,0} price_{1,1} ... price_{1,k-1}
...
price_{n-1,0} price_{n-1,1} ... price_{n-1,k-1}

其中 $\text{price}_{i,j}$ 是一个整数,表示第 $i$ 只股票在时间 $j$ 的价格。

输出格式

对于每个测试用例,输出一行 "Case #X: Y",其中 $X$ 是测试用例的编号(从 1 开始),$Y$ 是展示所有股票价格所需的最少叠加图表数量。

数据范围

$1 \le T \le 100$

$2 \le k \le 25$

$0 \le \text{price}_{i,j} \le 1000000$

小数据(7 分)

$1 \le n \le 16$

大数据(21 分)

$1 \le n \le 100$

样例

样例输入 1

3
3 4
1 2 3 4
2 3 4 6
6 5 4 3
3 3
5 5 5
4 4 6
4 5 4
5 2
1 1
2 2
5 4
4 4
4 1

样例输出 1

Case #1: 2
Case #2: 3
Case #3: 2

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.