编程介的小学生 2019-08-26 21:48 采纳率: 20.5%
浏览 64

Replica Placement代码的程序编写

Problem Description
Topsky wants to build a content delivery network. It contains an origin server and some mirror servers as shown in figure 1. Original data is put at the origin server (root in figure 1) while replicas are put at some of the mirror servers (node 2 and 5 in figure 1). When a node issues a request of data, it will try to find its destination in following steps.
1. Check if there is a replica at its own place. If yes, the request meets. Otherwise do step 2.
2. Forward the request to its parent, and let its parent do step 1.

The cost of meeting the request C (v) is defined as the sum of weight of the edges along the road. If C (v) is not greater than an upper bound Q (v), then the retrieval cost is satisfied. Topsky further assumes a nonnegative cost S (v) which means the cost of storing data at node v. Note that the origin server is special, the cost of storing data at origin server is 0. Now Topsky wants to find the way of replicas placement such the retrieval cost of all nodes are satisfied while the total storage cost is minimal.

Input
The first line contains a single integer T (T <= 20), indicating the number of test cases.
Each case begins with three integers N (1<= N <= 1000) indicates the number of servers.
Then N lines follow. Each line contains four integers Fv (0 <= Fv <= N), Qv, Sv and Wv (0 <= Qv, Sv, Wv <= 105). In line i (1 <= i <= N), Fv is the father of node i (if Fv is 0, it means node i is the origin server, Qv is -1, Sv is 0 and Wv is 0), Qv is upper bound of retrieval cost, Sv is storing cost of node i and Wv is weight of this edge between node i and node Fv.

Output
For each test case, output the minimal storage cost in one line.

Sample Input
1
3
0 -1 0 0
1 1 1 1
2 1 1 1

Sample Output
1

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)