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

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 極限定律 閱讀(611) 評論(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>
            久久久九九九九| 欧美久久婷婷综合色| 国产亚洲精品激情久久| 欧美伊人久久| 久久精品国产2020观看福利| 亚洲电影免费| 亚洲美女中出| 国产视频不卡| 欧美黄在线观看| 欧美日韩人人澡狠狠躁视频| 亚洲一区二区三区免费观看| 亚洲一区二区三区影院| 黄色成人av在线| 91久久香蕉国产日韩欧美9色| 欧美激情视频在线播放| 午夜一区二区三区不卡视频| 久久精品人人做人人综合| 最新国产成人在线观看| 亚洲一区免费| 亚洲日产国产精品| 午夜亚洲福利| 99视频+国产日韩欧美| 欧美一区二区国产| 夜夜嗨av一区二区三区四区| 亚洲欧美另类在线| 亚洲日本欧美天堂| 亚洲欧美日本日韩| 日韩一区二区福利| 久久不射网站| 亚洲欧美日韩一区在线| 免费欧美在线| 久久国产精品一区二区三区| 欧美另类视频| 欧美成人免费网站| 国产午夜精品在线观看| 亚洲狼人精品一区二区三区| 国模吧视频一区| 99re热这里只有精品免费视频| 国产有码一区二区| 亚洲午夜女主播在线直播| 亚洲毛片在线看| 久久久精品五月天| 欧美一区中文字幕| 欧美性猛交视频| 亚洲免费电影在线观看| 亚洲福利专区| 久久久久www| 久久aⅴ国产紧身牛仔裤| 欧美日韩中文字幕日韩欧美| 欧美国产日韩一区二区在线观看 | 久久综合成人精品亚洲另类欧美| 欧美日韩mp4| 亚洲国产美女| 亚洲国产精品久久久久| 久久久精品国产一区二区三区 | 亚洲少妇中出一区| 欧美大片免费| 亚洲福利国产| 日韩视频中文字幕| 欧美国产一区在线| 亚洲国产精品专区久久| 亚洲国产精品一区二区www| 久久夜色精品| 欧美电影专区| 亚洲精品激情| 欧美人与性动交α欧美精品济南到| 欧美成在线观看| 亚洲精选91| 欧美日韩中文字幕在线视频| 日韩亚洲欧美一区| 亚洲免费中文字幕| 国产午夜精品久久| 久久久久网址| 亚洲国产老妈| 亚洲视频在线观看免费| 国产精品久久久久影院亚瑟 | 99精品欧美一区二区三区综合在线| 日韩视频在线永久播放| 欧美日韩在线精品| 亚洲无线观看| 久久亚洲高清| 一本久道久久综合婷婷鲸鱼| 欧美日韩亚洲综合| 校园春色国产精品| 欧美激情五月| 国产精品99久久久久久有的能看| 欧美午夜精品一区| 欧美中文字幕不卡| 亚洲国产精品传媒在线观看 | 韩国一区二区三区美女美女秀| 久久久噜噜噜久久中文字免| 91久久精品国产91久久性色tv| av成人激情| 国产综合精品| 欧美激情第一页xxx| 亚洲在线播放| 亚洲国产精品成人综合色在线婷婷| 中文精品一区二区三区 | 欧美精品自拍| 亚洲欧美在线观看| 欧美国产精品久久| 欧美诱惑福利视频| 亚洲精品在线观看免费| 国产视频亚洲精品| 欧美日韩天堂| 久久亚洲精选| 午夜精品999| 日韩亚洲欧美在线观看| 欧美freesex交免费视频| 亚洲一区二区三区乱码aⅴ| …久久精品99久久香蕉国产 | 欧美日韩视频一区二区三区| 欧美在线一区二区| 99综合在线| 亚洲电影av在线| 久久九九有精品国产23| 亚洲愉拍自拍另类高清精品| 亚洲高清av| 韩日精品视频一区| 国产精品稀缺呦系列在线| 欧美精选一区| 玖玖玖免费嫩草在线影院一区| 亚洲一级一区| 日韩视频一区二区三区| 亚洲高清激情| 欧美国产国产综合| 久久人人爽人人| 久久久精品日韩欧美| 亚洲欧美日韩一区在线| 亚洲影院色无极综合| 一本色道久久88精品综合| 亚洲二区精品| 亚洲国产福利在线| 亚洲电影免费| 最新国产成人在线观看| 亚洲国产精品免费| 亚洲第一色中文字幕| 在线欧美日韩| 亚洲韩国青草视频| 亚洲国产婷婷香蕉久久久久久99 | 欧美高清视频一二三区| 久久噜噜噜精品国产亚洲综合 | 在线视频欧美日韩精品| 亚洲精品免费一二三区| 亚洲国产清纯| 亚洲免费av电影| 亚洲最新视频在线| 中日韩男男gay无套 | 欧美高清hd18日本| 欧美激情精品久久久| 亚洲国产成人精品久久| 亚洲激情精品| 一本久久精品一区二区| 亚洲直播在线一区| 久久超碰97人人做人人爱| 久久婷婷蜜乳一本欲蜜臀| 免费观看30秒视频久久| 欧美精品在线一区| 国产精品激情| 韩国av一区二区三区在线观看| 一区二区三区在线观看欧美| 亚洲人成人99网站| 亚洲性夜色噜噜噜7777| 久久国产精品亚洲77777| 美日韩免费视频| 亚洲精品国产精品国自产在线| 亚洲毛片一区| 欧美一区二区三区视频在线观看 | 欧美不卡视频一区| 欧美午夜激情视频| 国内精品久久久久久久97牛牛| 亚洲国产精彩中文乱码av在线播放| 亚洲人成小说网站色在线| 亚洲自拍偷拍麻豆| 美国十次成人| 在线性视频日韩欧美| 久久久久免费| 国产精品盗摄一区二区三区| 激情五月婷婷综合| 中文欧美在线视频| 免费看黄裸体一级大秀欧美| 日韩一区二区精品| 久久久久成人精品免费播放动漫| 欧美久久久久免费| 一区视频在线播放| 亚洲欧美日韩国产精品| 亚洲第一区在线| 午夜一区二区三视频在线观看| 欧美国产专区| 精久久久久久久久久久| 亚洲欧美激情一区| 亚洲第一天堂无码专区| 欧美一区二区三区免费观看| 欧美日韩国产a| 亚洲国产高潮在线观看| 久久成人18免费观看| 一区二区三区久久久| 欧美国产欧美亚洲国产日韩mv天天看完整| 国产精品天美传媒入口| 亚洲私拍自拍|