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

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 極限定律 閱讀(605) 評論(0)  編輯 收藏 引用 所屬分類: TopCoder

<2025年9月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

導航

統計

常用鏈接

留言簿(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>
            99精品久久久| 久久免费视频在线| 欧美日精品一区视频| 亚洲一区二区三区激情| 久久久www免费人成黑人精品| 9人人澡人人爽人人精品| 亚洲主播在线观看| 久久精品一区二区三区不卡| 亚洲一级网站| 国产精品国产三级国产aⅴ无密码| 亚洲先锋成人| 欧美一区二区视频观看视频| 好看的亚洲午夜视频在线| 欧美日韩三级一区二区| 欧美一区二区三区在| 欧美jjzz| 久久一区二区三区四区五区| 亚洲在线视频网站| 欧美人与性动交a欧美精品| 国产亚洲欧洲997久久综合| 91久久久久久国产精品| 久久精品久久99精品久久| 亚洲高清不卡在线| 亚洲视频 欧洲视频| 牛人盗摄一区二区三区视频| 国产精品第2页| 亚洲剧情一区二区| 欧美一区二区三区四区在线| 一区二区高清视频在线观看| 亚洲美女一区| 亚洲国产二区| 国产专区精品视频| 欧美久久电影| 亚洲欧美国产va在线影院| 亚洲视频二区| 欧美欧美午夜aⅴ在线观看| 久久er精品视频| 一区在线视频| 亚洲电影一级黄| 欧美日韩在线高清| 久久久久久久999精品视频| 一区二区三区四区国产精品| 一区二区三区视频在线看| 欧美日韩一区三区四区| 亚洲精选国产| 亚洲电影专区| 久久精品首页| 欧美成人中文字幕| aⅴ色国产欧美| 中文在线不卡视频| 久久国产日本精品| 久久亚裔精品欧美| 亚洲精品在线看| 国产香蕉97碰碰久久人人| 亚洲麻豆av| 亚洲麻豆一区| 亚洲电影免费在线| 影音先锋中文字幕一区| 欧美不卡一卡二卡免费版| 一本一本a久久| 欧美xart系列高清| 日韩亚洲成人av在线| 欧美顶级少妇做爰| 免费成人网www| 欧美影视一区| 久久亚洲精品一区二区| 久久久久久成人| 久久爱www| 欧美激情精品久久久久久久变态| 久久久www成人免费精品| 欧美高清在线观看| 亚洲制服少妇| 国产一区二区三区奇米久涩| 国产欧美日韩亚洲一区二区三区| 久久精品视频一| 蜜臀a∨国产成人精品| 久久精品中文字幕免费mv| 欧美一区二区精美| 欧美在线观看一二区| 久久精品视频99| 久久精品国产综合| 欧美小视频在线| 国产精品久久久久秋霞鲁丝| 香蕉国产精品偷在线观看不卡| 亚洲欧美在线免费| 99国产精品久久久久老师| 久久久亚洲综合| 99人久久精品视频最新地址| 美女主播视频一区| 久久青青草综合| 亚洲精品中文在线| 亚洲一区激情| 国产一区二区三区在线观看免费视频| 亚洲影院在线| 午夜激情亚洲| 欧美午夜视频在线观看| 黄色av成人| 久久久久国色av免费观看性色| 亚洲精品国产精品国自产观看浪潮| 亚洲欧美视频一区二区三区| 欧美国产高清| 一区二区精品国产| 一本久久知道综合久久| 欧美精选一区| 久久综合久久综合久久| 亚洲欧美色一区| 国产精品私人影院| 午夜精品久久久| 久久爱另类一区二区小说| 尤物网精品视频| 久久久蜜臀国产一区二区| 另类欧美日韩国产在线| 亚洲欧洲精品一区二区三区不卡 | 在线视频亚洲一区| 欧美激情欧美激情在线五月| 午夜在线一区| 日韩视频专区| 午夜亚洲性色福利视频| 亚洲午夜精品17c| 激情视频一区二区| 久久9热精品视频| 99re66热这里只有精品3直播| 亚洲国产精品va在线观看黑人| 亚洲欧美在线播放| 久久精品国产视频| 欧美性事免费在线观看| 亚洲一卡二卡三卡四卡五卡| 久久精品99国产精品酒店日本| 国外精品视频| 亚洲无限av看| 亚洲午夜精品久久| 欧美国产视频日韩| aa成人免费视频| 亚洲高清在线视频| 久久一区中文字幕| 久久精品99国产精品| 在线观看一区视频| 韩国亚洲精品| 在线视频你懂得一区| 久久躁日日躁aaaaxxxx| 亚洲一区二区精品在线| 欧美精品久久久久a| 亚洲福利国产精品| 亚洲第一综合天堂另类专| 久久久www成人免费毛片麻豆| 久久精品视频免费| 国产亚洲女人久久久久毛片| 亚洲免费在线精品一区| 亚洲制服欧美中文字幕中文字幕| 欧美日韩mv| 99精品热视频| 欧美一区二区在线视频| 国产视频在线一区二区| 久久成人资源| 欧美国产日韩一区二区三区| 亚洲高清久久久| 欧美高清一区二区| 一区二区高清在线| 欧美尤物巨大精品爽| 国产一区美女| 麻豆精品91| 日韩亚洲欧美在线观看| 亚洲欧美成人网| 国产一区二区三区高清在线观看 | 亚洲欧美在线aaa| 久久久一二三| 在线视频亚洲一区| 韩国一区二区三区美女美女秀| 中日韩美女免费视频网站在线观看| 欧美日韩亚洲天堂| 校园春色综合网| 亚洲电影一级黄| 一区二区三区欧美| 国产亚洲一区二区在线观看| 久久综合综合久久综合| 日韩视频中午一区| 久久九九全国免费精品观看| 亚洲欧洲精品一区二区| 国产精品美女久久福利网站| 久久九九精品| 一本色道久久| 久色婷婷小香蕉久久| 亚洲系列中文字幕| 亚洲国产精品女人久久久| 国产精品入口日韩视频大尺度| 在线中文字幕日韩| 亚洲精品国产精品国自产观看浪潮| 欧美午夜久久久| 欧美1区2区| 久久精视频免费在线久久完整在线看| 日韩亚洲在线观看| 亚洲福利视频专区| 久久在线播放| 久久久久久亚洲精品不卡4k岛国| 一区二区毛片| 日韩午夜免费| 亚洲片在线资源| 亚洲成色最大综合在线| 国产一区视频网站| 国产日韩精品一区观看|