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

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所需的時間。現在需要遍歷圖中所有的點,問所需要的最少時間是多少。
    這類題目有一種一般的做法:設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 極限定律 閱讀(609) 評論(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>
            亚洲国产成人久久| 欧美成人综合一区| 国产精品亚洲激情| 欧美精品自拍| 久久久久久999| 亚久久调教视频| 亚洲欧美日韩专区| 久久精品日产第一区二区| 亚洲永久精品国产| 久久免费视频网| 蜜臀va亚洲va欧美va天堂 | 国产欧美日韩在线| 欧美性猛交xxxx免费看久久久 | 狠狠爱综合网| 欧美日韩mp4| 日韩一区二区精品视频| 亚洲女同同性videoxma| 亚洲国产精品久久91精品| 久久三级视频| 免费观看成人鲁鲁鲁鲁鲁视频| 亚洲高清二区| 欧美日韩成人综合天天影院| 亚洲黑丝一区二区| 夜夜爽www精品| 嫩模写真一区二区三区三州| 久久久精品一区| 久久蜜桃精品| 亚洲你懂的在线视频| 日韩视频一区二区| 亚洲午夜女主播在线直播| 欧美日韩成人| 中文国产一区| 亚洲欧洲视频| 性欧美大战久久久久久久久| 国产女精品视频网站免费| 亚洲国产视频a| 亚洲性夜色噜噜噜7777| 国产亚洲一区二区精品| 久久久综合网| 欧美日韩岛国| 欧美日韩成人网| 亚洲国产一区二区三区a毛片 | 亚洲欧美日韩精品久久亚洲区| 久久久久久一区二区| 国产精品亚洲激情| 亚洲第一黄网| 欧美一进一出视频| 午夜精品久久99蜜桃的功能介绍| 欧美精品在线极品| 亚洲一区免费看| 曰韩精品一区二区| 欧美国产综合| 欧美日韩精品在线| 亚洲一区免费在线观看| 亚洲午夜精品久久| 久久综合五月天婷婷伊人| 国产精品青草久久久久福利99| 亚洲精品一区二区三| 久热精品视频| 欧美第十八页| 午夜精品久久久久久久白皮肤| 一区二区三区www| 欧美三区美女| 欧美成人一区二区三区在线观看| 亚洲一本视频| 欧美一区久久| 亚洲精品在线观| 国产精品99久久久久久久vr | 蜜桃久久av一区| 另类av一区二区| 亚洲一区二区毛片| 亚洲欧美另类在线观看| 亚洲精品乱码久久久久久蜜桃麻豆| 亚洲国产裸拍裸体视频在线观看乱了| 免费欧美网站| 久久这里有精品15一区二区三区| 欧美成人dvd在线视频| 欧美在线高清| 国产精品护士白丝一区av| 亚洲二区免费| 亚洲国产精品久久久久秋霞不卡| 在线视频一区二区| 久久激情久久| 亚洲欧美日韩国产中文在线| 久久一区二区三区国产精品| 欧美亚洲在线播放| 国产精品女主播一区二区三区| 亚洲福利在线视频| 亚洲第一在线综合网站| 久久精品国亚洲| 欧美高清视频在线播放| 亚洲人人精品| 欧美三级午夜理伦三级中文幕 | 国产精品一区二区久久国产| 欧美xart系列在线观看| 亚洲国产91色在线| 欧美大成色www永久网站婷| 亚洲人成在线播放| 亚洲一区国产精品| 狠狠干综合网| 欧美日韩第一区日日骚| aa级大片欧美| 午夜视频在线观看一区二区三区| 国产精品国产三级国产aⅴ入口| 亚洲人成网站精品片在线观看 | 99re66热这里只有精品4| 最新亚洲电影| 国产一区在线观看视频| 欧美精品v日韩精品v韩国精品v | 欧美在线网址| 亚洲愉拍自拍另类高清精品| 精品1区2区3区4区| 亚洲高清资源| 久久久噜噜噜久久中文字免| 亚洲电影在线| 国产原创一区二区| 国产一二三精品| 国产偷自视频区视频一区二区| 欧美日韩免费视频| 欧美精品一区二区在线观看| 久久免费高清| 欧美成人午夜视频| 欧美 日韩 国产一区二区在线视频| 亚洲愉拍自拍另类高清精品| 亚洲三级免费电影| 久久久久免费| 久久久噜噜噜久久中文字幕色伊伊 | 亚洲国产精品国自产拍av秋霞| 国产精品一级二级三级| 午夜精品国产精品大乳美女| 亚洲国产精品成人精品| 亚洲国产一区二区视频| 午夜性色一区二区三区免费视频 | 亚洲人在线视频| 亚洲精品国产视频| 欧美区高清在线| 国产色产综合产在线视频| 国产日韩欧美视频在线| 亚洲欧洲综合另类在线| 亚洲一区精品在线| 久久一区二区精品| 99精品视频一区| 欧美一区二区三区四区视频 | 欧美一级视频精品观看| 免费h精品视频在线播放| 黄色精品一区| 性8sex亚洲区入口| 国内精品99| 国产精品日韩精品欧美在线| 国产真实乱偷精品视频免| 欧美亚洲在线视频| 久久福利精品| 91久久精品国产| 亚洲免费高清| 一区二区三区欧美| 午夜精品久久久久久99热| 国产精品无码专区在线观看| 久久久无码精品亚洲日韩按摩| 久久精品日产第一区二区| 亚洲精品网址在线观看| 亚洲深爱激情| 亚洲精品男同| 欧美专区在线播放| 一本一本久久a久久精品综合妖精| 亚洲自拍偷拍麻豆| 激情综合自拍| 亚洲影院在线观看| 日韩一区二区精品| 久久黄色网页| 性欧美1819sex性高清| 欧美国产在线观看| 看片网站欧美日韩| 国产精品xxx在线观看www| 久久综合九色综合欧美就去吻| 欧美黄色小视频| 亚洲日韩第九十九页| 禁断一区二区三区在线| 日韩视频中文字幕| 亚洲午夜av在线| 国产精品久久久爽爽爽麻豆色哟哟| 亚洲成人直播| 亚洲国产日韩欧美| 女人天堂亚洲aⅴ在线观看| 免费看精品久久片| 亚洲区第一页| 国产乱码精品| 亚洲一区在线免费观看| 亚洲欧美大片| 国产亚洲电影| 性做久久久久久| 欧美国产日韩一区二区三区| 欧美在线高清| 国产日本欧美一区二区三区| 香蕉国产精品偷在线观看不卡| 日韩视频一区二区三区| 久久久999| 亚洲狼人精品一区二区三区| 久久免费视频在线| 亚洲图片你懂的| 1024精品一区二区三区|