编程介的小学生 2017-01-11 14:32 采纳率: 20.5%
浏览 899
已采纳

Porcelain Exhibitions

问题描述 :

Recently, the Chinese government is going to hold a porcelain exhibition in every province.
For fascinating citizens, each exhibition should put at least MIN_K porcelains on show. And by the restriction of conditions, at most MAX_K porcelains can be shown in an exhibition.

The number of porcelains in a province is in direct proportion to the area of that province. So some small provinces may don’t have enough porcelains, and some big provinces may have more porcelains than it can show(having too much porcelains is not a problem for holding an exhibition, just don’t show some of them). The government decides to transport some porcelains between provinces so that every province can hold an exhibition.

Because of the limitation of traffic, the amount of porcelains passing a boundary between two provinces is limited. So the government asks you to write a program to manage the transportation.

The map of China can be seen as a connected planar graph embedded on a plane. Each face of the graph represents a province. This graph has N vertices and M edges. A vertex of the graph is also a point on the map, and an edge is also a line segment connecting two points, meaning a boundary between two provinces.

输入:

The input will consist of multiply test cases. For each case, The first line contains five positive integers — above mentioned N, M, MIN_K,MAX_K and P( N <= 1000,M <= 10000, MIN_K < MAX_K) . P means that if the area of a province is A, then there are A×P porcelains in that province. P is guaranteed to be even so that the amount of porcelains in each province will be a positive integer.

The next N lines, each gives two integer x, y, representing the coordinate of a vertex(Vertexes have distinct coordinates). The vertexes are numbered from 0 to N-1 and the coordinates are given in the order of vertex No.

The next M lines, each gives three integers u,v, and w. It means that there is an edge connecting vertex u and vertex v. The edge is also a boundary between two provinces. w means that the boundary can’t let more than w porcelains to pass through. (w for the boundary of China is 0, and boundaries don’t overlap). The number of province is less than 2000.
Unsigned int is enough for this problem. The input ends with 0 0 0 0 0.

输出:

The input will consist of multiply test cases. For each case, The first line contains five positive integers — above mentioned N, M, MIN_K,MAX_K and P( N <= 1000,M <= 10000, MIN_K < MAX_K) . P means that if the area of a province is A, then there are A×P porcelains in that province. P is guaranteed to be even so that the amount of porcelains in each province will be a positive integer.

The next N lines, each gives two integer x, y, representing the coordinate of a vertex(Vertexes have distinct coordinates). The vertexes are numbered from 0 to N-1 and the coordinates are given in the order of vertex No.

The next M lines, each gives three integers u,v, and w. It means that there is an edge connecting vertex u and vertex v. The edge is also a boundary between two provinces. w means that the boundary can’t let more than w porcelains to pass through. (w for the boundary of China is 0, and boundaries don’t overlap). The number of province is less than 2000.
Unsigned int is enough for this problem. The input ends with 0 0 0 0 0.

样例输入:

8 9 5 8 2
0 0
0 3
3 3
3 0
1 1
1 2
2 2
2 1
0 1 0
1 2 0
2 3 0
3 0 0
4 5 1
5 6 1
6 7 1
7 4 1
0 4 1
8 9 7 8 2
0 0
0 3
3 3
3 0
1 1
1 2
2 2
2 1
0 1 0
1 2 0
2 3 0
3 0 0
4 5 1
5 6 1
6 7 1
7 4 1
0 4 1
0 0 0 0 0
样例输出:

14
-1

  • 写回答

1条回答

  • threenewbee 2017-01-18 15:56
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 fluent无法启动
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架
  • ¥15 有关sql server business intellige安装,包括SSDT、SSMS。