青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

SRM 144 DIV 2 1100

Problem Statement

    

You work for an electric company, and the power goes out in a rather large apartment complex with a lot of irate tenants. You isolate the problem to a network of sewers underneath the complex with a step-up transformer at every junction in the maze of ducts. Before the power can be restored, every transformer must be checked for proper operation and fixed if necessary. To make things worse, the sewer ducts are arranged as a tree with the root of the tree at the entrance to the network of sewers. This means that in order to get from one transformer to the next, there will be a lot of backtracking through the long and claustrophobic ducts because there are no shortcuts between junctions. Furthermore, it's a Sunday; you only have one available technician on duty to search the sewer network for the bad transformers. Your supervisor wants to know how quickly you can get the power back on; he's so impatient that he wants the power back on the moment the technician okays the last transformer, without even waiting for the technician to exit the sewers first.

You will be given three vector <int>'s: fromJunction , toJunction, and ductLength that represents each sewer duct. Duct i starts at junction (fromJunction[i] ) and leads to junction (toJunction[i]). ductlength[i] represents the amount of minutes it takes for the technician to traverse the duct connecting fromJunction[i] and toJunction[i]. Consider the amount of time it takes for your technician to check/repair the transformer to be instantaneous. Your technician will start at junction 0 which is the root of the sewer system. Your goal is to calculate the minimum number of minutes it will take for your technician to check all of the transformers. You will return an int that represents this minimum number of minutes.

Definition

    
Class: PowerOutage
Method: estimateTimeOut
Parameters: vector <int>, vector <int>, vector <int>
Returns: int
Method signature: int estimateTimeOut(vector <int> fromJunction, vector <int> toJunction, vector <int> ductLength)
(be sure your method is public)

    題目意思:圖中有n個點,從邊(u,v)的權值是點u到點v所需的時間?,F在需要遍歷圖中所有的點,問所需要的最少時間是多少。
    這類題目有一種一般的做法:設ans=2*∑cost(u,v),為所有邊的權值的和的2倍;再從起點s找一條簡單路徑path,滿足:path上的所有權值之和最大;這個可以用一個簡單的dfs輕松搞定;最后ans-path就是所需的最短時間。
#include <iostream>
#include 
<vector>
#include 
<algorithm>
using namespace std;

class PowerOutage{
public:
    
int estimateTimeOut(vector<int> fromJunction, vector<int> toJunction, vector<int> ductLength);
    
int dfs(int index, vector<int> fromJunction, vector<int> toJunction, vector<int> ductLength);
}
;
int PowerOutage::dfs(int index, vector<int> fromJunction, vector<int> toJunction, vector<int> ductLength){
    
int i,ans=0,len=fromJunction.size();
    
for(i=0;i<len;i++)
        
if(fromJunction[i]==index)
            ans
=max(ans,ductLength[i]+dfs(toJunction[i],fromJunction,toJunction,ductLength));
    
return ans;
}

int PowerOutage::estimateTimeOut(vector<int> fromJunction, vector<int> toJunction, vector<int> ductLength){
    
int i,ans=0,len=ductLength.size();
    
for(i=0;i<len;i++)
        ans
+=2*ductLength[i];
    ans
-=dfs(0,fromJunction,toJunction,ductLength);
    
return ans;
}

posted on 2009-05-23 14:42 極限定律 閱讀(612) 評論(0)  編輯 收藏 引用 所屬分類: TopCoder


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


<2009年5月>
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

導航

統計

常用鏈接

留言簿(10)

隨筆分類

隨筆檔案

友情鏈接

搜索

最新評論

閱讀排行榜

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            久久国产精品一区二区三区| 亚洲欧美高清| 久久一本综合频道| 国内精品久久久久久久果冻传媒| 欧美一站二站| 久久不射2019中文字幕| 狠狠88综合久久久久综合网| 老**午夜毛片一区二区三区| 卡通动漫国产精品| 99视频一区二区三区| 亚洲麻豆av| 国产精品无码专区在线观看| 久久久久**毛片大全| 久久一区免费| 一区二区三区成人| 午夜视频一区二区| 在线观看亚洲一区| 亚洲作爱视频| 国产在线精品一区二区中文 | 国产精品成人在线| 欧美诱惑福利视频| 美女啪啪无遮挡免费久久网站| 亚洲免费观看高清在线观看| 亚洲午夜精品视频| 一区二区三区在线视频免费观看| 亚洲电影观看| 欧美日韩另类在线| 久久精品免费| 欧美日韩国产限制| 玖玖精品视频| 国产精品久久国产愉拍| 六月婷婷一区| 国产精品r级在线| 国产视频自拍一区| 亚洲精品久久嫩草网站秘色| 国产日韩欧美精品一区| 亚洲激情综合| 午夜精品理论片| 亚洲精品中文字幕有码专区| 亚洲一区www| 亚洲美女黄色| 久久在线免费| 亚欧成人在线| 欧美日韩黄视频| 美女图片一区二区| 国产欧美日韩不卡免费| 亚洲精品视频在线观看网站| 亚洲电影av| 欧美在线免费| 久久成人一区| 一区二区三区黄色| 亚洲人成在线免费观看| 久久九九全国免费精品观看| 欧美在线免费观看| 欧美性大战久久久久久久蜜臀| 亚洲国产一区二区三区青草影视| 国语自产精品视频在线看| 亚洲一区二区在线免费观看视频| 欧美高清视频| 欧美成人按摩| 在线日韩欧美视频| 久久久久这里只有精品| 久久视频一区二区| 国产欧美一区二区在线观看| 亚洲淫性视频| 欧美一区二区三区在线| 国产日韩亚洲欧美精品| 亚洲午夜未删减在线观看| 欧美第一黄网免费网站| 亚洲国产裸拍裸体视频在线观看乱了| 国自产拍偷拍福利精品免费一| 欧美一区二区三区免费看| 欧美在线999| 国内成+人亚洲+欧美+综合在线| 亚洲欧美国产视频| 久久国产99| 欧美一区二区视频在线观看2020 | 国产亚洲成精品久久| 亚洲伊人伊色伊影伊综合网 | 亚洲第一精品夜夜躁人人躁| 久久亚洲精品伦理| 欧美激情国产日韩精品一区18| 久久久久久久久久码影片| 久热精品在线| 亚洲福利小视频| 欧美片第1页综合| 夜夜嗨网站十八久久| 篠田优中文在线播放第一区| 国产日韩亚洲欧美精品| 久久亚洲私人国产精品va| 亚洲品质自拍| 欧美一级网站| 另类欧美日韩国产在线| 亚洲精品一区二区网址| 亚洲欧美一区二区三区在线| 国产在线不卡精品| 欧美激情国产精品| 亚洲综合999| 欧美高清成人| 午夜精品免费| 亚洲国产日韩欧美在线图片| 亚洲精品一区二区三区婷婷月| 欧美一级在线播放| 亚洲福利电影| 国产精品久久久久久亚洲调教| 久久久久久久国产| 日韩视频在线一区| 免费久久99精品国产自| 亚洲一区二区视频在线| 伊人男人综合视频网| 欧美色区777第一页| 久久婷婷丁香| 亚洲一区二区免费| 亚洲国产美国国产综合一区二区| 欧美中文在线字幕| 亚洲精品中文字幕女同| 精品69视频一区二区三区| 欧美日韩在线看| 裸体歌舞表演一区二区| 亚洲欧美在线观看| 亚洲毛片av在线| 欧美成人蜜桃| 久久久精品2019中文字幕神马| 一区二区三区四区五区精品视频| 尤物99国产成人精品视频| 国产精品丝袜久久久久久app| 看欧美日韩国产| 欧美一区二区三区免费大片| 中国女人久久久| 亚洲伦理网站| 亚洲精品你懂的| 久久久水蜜桃| 久久国产精品久久久久久| 亚洲校园激情| 在线亚洲一区二区| 一区二区三区国产| 亚洲毛片视频| 亚洲免费激情| 一本一本久久a久久精品综合妖精 一本一本久久a久久精品综合麻豆 | 在线免费观看成人网| 国产一区二区三区在线观看网站| 亚洲视频在线观看| 夜夜躁日日躁狠狠久久88av| 91久久国产综合久久91精品网站| 欧美成人免费网站| 欧美福利网址| 亚洲国产精品ⅴa在线观看| 欧美18av| 亚洲狠狠丁香婷婷综合久久久| 欧美韩日视频| 亚洲国产精品女人久久久| 精品不卡视频| 亚洲日本免费电影| 亚洲精品一区在线| 一区二区三区导航| 亚洲欧美日韩国产综合精品二区 | 亚洲第一页在线| 亚洲国产第一| 99re国产精品| 亚洲在线一区二区| 欧美性色综合| 国产日韩精品一区二区浪潮av| 国产亚洲免费的视频看| 狠狠色2019综合网| 亚洲大胆在线| 99国内精品久久| 午夜伦欧美伦电影理论片| 久久激情婷婷| 亚洲电影毛片| 一区二区冒白浆视频| 性色av一区二区三区| 久久综合久久综合这里只有精品| 欧美va天堂在线| 国产精品swag| 永久久久久久| 亚洲伊人伊色伊影伊综合网| 欧美在线一级va免费观看| 欧美成人首页| 亚洲一区二区网站| 理论片一区二区在线| 欧美婷婷六月丁香综合色| 韩日视频一区| 亚洲一区久久久| 欧美69wwwcom| 亚洲无线一线二线三线区别av| 久久久久久电影| 欧美亚州韩日在线看免费版国语版| 国产欧美日韩一区| 亚洲免费观看在线观看| 久久精品国产91精品亚洲| 最新69国产成人精品视频免费| 亚洲欧美视频在线| 欧美激情a∨在线视频播放| 国产一区二区精品久久91| 一本色道88久久加勒比精品 | 99视频精品全部免费在线| 久久久激情视频| 一区二区三区久久网| 欧美v日韩v国产v| 国模 一区 二区 三区|