编程介的小学生 2020-01-17 21:49 采纳率: 20.5%
浏览 40

Porcelain Exhibitions 怎么编的程序

Problem Description
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.

Input
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.

Output
For each test case, print one integer in a line representing the maximal number of porcelains can be exhibited in whole country. If one or more province can’t hold an exhibition, print -1.

Sample Input
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

Sample Output
14
-1

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 全志H618ROM新增分区
    • ¥20 jupyter保存图像功能的实现
    • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
    • ¥15 NAO机器人的录音程序保存问题
    • ¥15 C#读写EXCEL文件,不同编译
    • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
    • ¥15 扩散模型sd.webui使用时报错“Nonetype”
    • ¥15 stm32流水灯+呼吸灯+外部中断按键
    • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
    • ¥15 NX MCD仿真与博途通讯不了啥情况