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

建议使用的浏览器:

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

1793:Storehouse

Special Judge 特殊评判
题目描述
Advanced Cargo Movement, Ltd. owns a big storehouse in which a lot of various goods is stored. The storehouse has limited number of bays where a cargo can be loaded. Each day, trucks come to the bays, load their cargo (each truck loads just one type of goods) and leave for the shops. In order to speedup the loading, storekeepers move the goods to the bay in advance. Since the exact quantity of cargo to be loaded is not known beforehand, the storekeepers must prepare more goods than needed and the left-over goods is then returned to the store. Thus, it is useful when the next truck coming to the bay loads the same goods as the previous one, because it saves unnecessary movement of cargo. The capacity of trucks is much smaller than the capacity of the bay, therefore, any number of trucks can be served from one bay without reloading, as long as they want to load the same type of goods.

Your task is to organize which type of goods will be prepared in which bay, so that storekeepers must move the unloaded goods back to the storehouse as few times as possible. At the beginning of each day, no goods is prepared in any bay. The goods left in bays at the end of the day is not counted to the number of moves needed.
输入解释
The first line of the input contains the number of test cases to solve. Each test case starts with the line containing three integer numbers, B, G, N, 1 <= B <= 1 000, 1 <= G <= 1 000 000, 1 <= N <= 1 000 000, separated by a single space. B is the number of bays in the storehouse, G the number of types of goods stored in the storehouse and N the number of trucks coming to the storehouse. The test case continues by N lines. On the i-th line, there is a number ti, 1 <= ti <= G, specifying the type of goods the i-th truck wants to load.
输出解释
For each test case, your program should output "Case X:" on the first line, where X is the case number starting with one. Then N lines follow. For each i, 1 <= i <= N, the i-th line must contain one of the following strings:
"NO ACTION" -- when no action needs to be performed before the arrival of the truck i(i.e., the goods i-th truck wants to load is already at some bay), or
"LOAD b g" -- when the goods with number g should be moved to the bay b before the i-th truck arrives. The goods currently present at the bay b is automatically moved back to the storehouse.
Each time some truck arrives, the goods it wants to load must be prepared at some bay. Assume that any truck leaves the bay before the next one arrives, i.e., only a single truck is served at a time.

The number of "LOAD" actions should be as small as possible. If there are more solutions with the same number of "LOAD" actions, choose any one you want. Outputs for different test cases should be separated by a blank line.
输入样例
2
2 4 5
1
2
1
4
1
3 3 3
1
3
2
输出样例
Case 1:
LOAD 1 1
LOAD 2 2
NO ACTION
LOAD 2 4
NO ACTION

Case 2:
LOAD 1 1
LOAD 2 3
LOAD 3 2

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 CTU Open 2003

源链接: POJ-1793

最后修改于 2020-10-29T06:14:08+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 30000