当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2387:Online Shopping

题目描述
The Internet becomes more and more important for our daily life. Aside from information retrieval, many people use the web for comfortable shopping from their home PCs. As the number of online customers grows, so does the number of websites dedicated to comparing online prices. Competitive sites need to quickly visualize the cheapest offers for a certain product. Barter & Haggle Inc. has recently been successful in the field of comparing online prices. However, as more and more comparable services appear, B&H has trouble conserving their market share. This is why the company has decided to improve its technology by comparing prices for different online shops and products simultaneously. The engineers have not been capable of implementing the visualization algorithm, though. This is where you come into play.

Given a table of prices for different products at different online stores, you need to find an optimal reordering of the rows and columns. In order to compare different reorderings, we define the table string to be the string of cells that is obtained from a table by appending all columns. An optimal reordering has the smallest table string with respect to lexicographical comparison (the table string is compared cell-wise).

输入解释
The inputs start with a line containing a single integer n. Each of the n following lines contains one test case. Each test case starts with two integers 1 <= a, b <= 5, the number of products and online shops respectively.
The table string consisting of the prices separated by single spaces follows. Each price p is given as an integer amount of cents with 0 <= p <= 109.
输出解释
The output for every test case begins with a line containing “Scenario #i:”, where i is the number of the test case counting from 1. Then, output a single line containing the table string of the optimal reordering of products and shops. Terminate each test case with an empty line.
输入样例
2
3 2 3999 5000 4000 4000 12999 9999
4 3 120 120 110 120 80 75 250 50 200 55 80 80
输出样例
Scenario #1:
3999 5000 4000 4000 12999 9999

Scenario #2:
50 200 250 80 75 120 80 80 55 120 110 120
来自杭电HDUOJ的附加信息
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-2387

最后修改于 2020-10-25T22:52:59+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)