3

自己设计的一道ACM风格的程序设计训练题:大货车极限送货

 3 years ago
source link: https://blog.csdn.net/yanxiangtianji/article/details/8190250
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

自己设计的一道ACM风格的程序设计训练题:大货车极限送货

最复杂版(可能NP,未证明):

A company has a central warehouse and a N clients that have to be supplied from that warehouse. A fleet of trucks is a available with T different trunks there which they don't share the same speed. And there are P pathes arround your company and clients, the distances of them are known. A truck can supply various clients on a single route. However, the total distance a truck is allowed to cover C is bounded.

You must arrange the route for your fleet to get a minimal total distance since the petrol is getting more and more expensive. Do remember truncks must return to your warehouse after they finished their jobs. Once the total distance is setted, you must make full use of your fleet to get a minimal cast time which is the time by which the last client is served.

All trunks started from the warehouse.

At least a solution is guaranteed.

Input:

First line 3 space seperated integers N,T,P mean number of clients, number of truncks, number pathes seperately.

The following T lines each contains 2 integer which means the speed and distance capacity of a trunk.

The following P lines each contains 3 integer (s,t,d) which means the distance from s to t is d.

(The index of the warehouse is 0, the other clients are represented as 1,2,3,...,P.)

Output:

Two integer:

Minimal total distance and minimal cast time of the distance.

下面从最简单开始逐步递增难度,并给出解题思路,供新手练习,大家交流使用。

最简单版:

你有一个配送公司,公司有一个仓库在A点,你有一辆卡车用来把货物从仓库送到一个客户(在B点)手里。公司附近的地图是已知的,从A点到B点之间你可能需要走到其他节点中转,你需要设计一个线路使总行驶距离最短。

思路:最短路径算法

第二版:

送到之后要返回公司。

思路:2次最短路径算法

(to be continued)


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK