设为首页 加入收藏

TOP

HDU 3339 In Action
2012-11-13 13:25:36 】 浏览:588
Tags:HDU  3339  In  Action
    题目:
   
    Problem Description

    Since 1945, when the first nuclear bomb was exploded by the Manhattan Project team in the US, the number of nuclear weapons have soared across the globe.
   
    Nowadays,the crazy boy in FZU named AekdyCoin possesses some nuclear weapons and wanna destroy our world. Fortunately, our mysterious spy-net has gotten his plan. Now, we need to stop it.
   
    But the arduous task is obviously not easy. First of all, we know that the operating system of the nuclear weapon consists of some connected electric stations, which forms a huge and complex electric network. Every electric station has its power value. To start the nuclear weapon, it must cost half of the electric network's power. So first of all, we need to make more than half of the power diasbled. Our tanks are ready for our action in the base(ID is 0), and we must drive them on the road. As for a electric station, we control them if and only if our tanks stop there. 1 unit distance costs 1 unit oil. And we have enough tanks to use.
   
    Now our commander wants to know the minimal oil cost in this action.
   
    Input
   
    The first line of the input contains a single integer T, specifying the number of testcase in the file.
   
    For each case, first line is the integer n(1<= n<= 100), m(1<= m<= 10000), specifying the number of the stations(the IDs are 1,2,3…n), and the number of the roads between the station(bi-direction)。
   
    Then m lines follow, each line is interger st(0<= st<= n), ed(0<= ed<= n), dis(0<= dis<= 100), specifying the start point, end point, and the distance between.
   
    Then n lines follow, each line is a interger pow(1<= pow<= 100), specifying the electric station's power by ID order.
   
    Output
   
    The minimal oil cost in this action.
   
    If not exist print “impossible”(without quotes)。
   
    Sample Input
   
    2
   
    2 3
   
    0 2 9
   
    2 1 3
   
    1 0 2
   
    1
   
    3
   
    2 1
   
    2 1 3
   
    1
   
    3
   
    Sample Output
   
    5
   
    impossible
   
    题意:有n个基地,分别标号1n,每个地点都有一定的能量,选择一些基地使得能量和大于总和的一半,当然这些选择的点是与0连通的。起点在编号为0的基地。
   
    分析:第一步:求起点为0,到其他点的最短路,
   
    第二步:01背包,cost[i] 为起点到 i 的最短路,weight[i] 为 i 的能量。
   
    注意:有重边,无数次WA = =!!

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇HDU 3853 LOOPS .. 下一篇练习c++ 函数模版例子

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目