Poj第1083题--Moving Tables
原题
Moving Tables
Description
The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure.
The floor has 200 rooms each on the north side and south side along the corridor. Recently the Company made a plan to reform its system. The reform includes moving a lot of tables between rooms. Because the corridor is narrow and all the tables are big, only one table can pass through the corridor. Some plan is needed to make the moving efficient. The manager figured out the following plan: Moving a table from a room to another room can be done within 10 minutes. When moving a table from room i to room j, the part of the corridor between the front of room i and the front of room j is used. So, during each 10 minutes, several moving between two rooms not sharing the same part of the corridor will be done simultaneously. To make it clear the manager illustrated the possible cases and impossible cases of simultaneous moving.
解题思路
将一组测试数据存放到一张二维数组m[1...n][2]中,其中m[1...n][0]存放搬桌子的起始点,m[1...n][1]存放搬桌子的终点。
然后将房间号转化为过道号。
最后遍历过道号数组,找到搬桌子经过次数最多的过道号,找到此最大的次数,这就是并行处理需要的最多的单位时间了。
算法实现
|
|