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

posts - 74,  comments - 33,  trackbacks - 0
Islands and Bridges
Time Limit: 4000MS Memory Limit: 65536K
Total Submissions: 2930 Accepted: 723

Description

Given a map of islands and bridges that connect these islands, a Hamilton path, as we all know, is a path along the bridges such that it visits each island exactly once. On our map, there is also a positive integer value associated with each island. We call a Hamilton path the best triangular Hamilton path if it maximizes the value described below.

Suppose there are n islands. The value of a Hamilton path C1C2...Cn is calculated as the sum of three parts. Let Vi be the value for the island Ci. As the first part, we sum over all the Vi values for each island in the path. For the second part, for each edge CiCi+1 in the path, we add the product Vi*Vi+1. And for the third part, whenever three consecutive islands CiCi+1Ci+2 in the path forms a triangle in the map, i.e. there is a bridge between Ci and Ci+2, we add the product Vi*Vi+1*Vi+2.

Most likely but not necessarily, the best triangular Hamilton path you are going to find contains many triangles. It is quite possible that there might be more than one best triangular Hamilton paths; your second task is to find the number of such paths.

Input

The input file starts with a number q (q<=20) on the first line, which is the number of test cases. Each test case starts with a line with two integers n and m, which are the number of islands and the number of bridges in the map, respectively. The next line contains n positive integers, the i-th number being the Vi value of island i. Each value is no more than 100. The following m lines are in the form x y, which indicates there is a (two way) bridge between island x and island y. Islands are numbered from 1 to n. You may assume there will be no more than 13 islands.

Output

For each test case, output a line with two numbers, separated by a space. The first number is the maximum value of a best triangular Hamilton path; the second number should be the number of different best triangular Hamilton paths. If the test case does not contain a Hamilton path, the output must be `0 0'.

Note: A path may be written down in the reversed order. We still think it is the same path.

Sample Input

2
3 3
2 2 2
1 2
2 3
3 1
4 6
1 2 3 4
1 2
1 3
1 4
2 3
2 4
3 4

Sample Output

22 3
69 1
以前做本校的1005的時候,其中就用到TSP,當然KM也能正確求解,暴搜更是無敵!
現在這是一道變形的TSP,搞清題目意思就很容易求解,不幸的是在統計路徑的時候,我居然
腦殘的sum++,而應該是sum+=dpways[(1<<n)-1][i][j];因此白白的貢獻了N個WA,
腦殘人士!請見諒!
代碼很慢,735ms,不貼了!
-------------------------------------------------------------------------------------------
上課去了!!!
posted on 2009-03-26 09:56 KNIGHT 閱讀(133) 評論(0)  編輯 收藏 引用

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


<2009年1月>
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

常用鏈接

留言簿(8)

隨筆檔案

文章檔案

Friends

OJ

搜索

  •  

最新評論

閱讀排行榜

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            国产精品日日做人人爱| 国产综合一区二区| 亚洲香蕉在线观看| 亚洲视频一区| 国产精品一区二区久激情瑜伽| 亚洲欧美成人一区二区三区| 亚洲性图久久| 狠狠色香婷婷久久亚洲精品| 欧美成人免费在线观看| 欧美精品免费在线| 亚洲一区二区免费| 欧美影院在线| 亚洲欧洲精品天堂一级| 亚洲精品一区二区三区av| 国产精品久久久久久久一区探花| 亚洲女人天堂av| 久久高清免费观看| 亚洲乱亚洲高清| 亚洲欧美精品在线观看| 永久免费精品影视网站| 亚洲人成网站精品片在线观看 | 久久久久久久性| 久久精品国产第一区二区三区最新章节| 在线日韩av片| 中文亚洲欧美| 亚洲高清一区二区三区| 日韩亚洲精品在线| 一区在线视频观看| 亚洲精选在线观看| 国内精品免费在线观看| 亚洲另类黄色| 尤物九九久久国产精品的分类| 亚洲人成欧美中文字幕| 国产婷婷97碰碰久久人人蜜臀| 欧美好骚综合网| 国产女优一区| 亚洲免费成人av| 影音先锋日韩资源| 亚洲欧美制服中文字幕| 99国产精品国产精品毛片| 久久国产高清| 亚洲在线电影| 欧美极品在线视频| 欧美不卡视频| 国内精品久久久久伊人av| 日韩午夜高潮| 亚洲日产国产精品| 久久人人爽爽爽人久久久| 午夜国产精品影院在线观看| 欧美激情无毛| 欧美99久久| 韩国精品一区二区三区| 亚洲自啪免费| 亚洲欧美国产视频| 欧美日韩激情小视频| 亚洲国产精品精华液2区45| 国产一区自拍视频| 午夜精品福利电影| 亚洲女同在线| 国产精品久久久久久福利一牛影视| 亚洲国产精品女人久久久| 影音先锋中文字幕一区| 久久精品99国产精品日本| 欧美在线视频不卡| 国产欧美日韩精品一区| 亚洲欧美激情诱惑| 久久激情五月激情| 国内精品国语自产拍在线观看| 午夜在线精品偷拍| 久久久久久婷| 精品不卡视频| 免费在线观看日韩欧美| 亚洲激情视频在线观看| 99国产精品久久久久久久| 欧美国产综合| 亚洲精品孕妇| 亚洲欧美精品suv| 国产日韩亚洲欧美精品| 久久精品国产77777蜜臀 | 最新亚洲激情| 欧美女主播在线| 一区二区三区久久| 久久精品成人一区二区三区蜜臀 | 久久久久久一区| 欧美91大片| 亚洲精品久久久一区二区三区| 91久久亚洲| 欧美精品一区二区三区蜜桃| 亚洲精品一二三区| 亚洲欧美三级伦理| 国产一区二区三区高清| 久久综合给合| 亚洲精品视频一区| 欧美中文字幕第一页| 在线精品国精品国产尤物884a| 欧美国产高潮xxxx1819| 一个人看的www久久| 久久国产精品黑丝| 亚洲级视频在线观看免费1级| 欧美日韩精品免费观看视一区二区| 亚洲伊人久久综合| 欧美aa国产视频| 亚洲欧美国产日韩天堂区| 激情综合色丁香一区二区| 欧美日韩国产三级| 欧美一区二视频在线免费观看| 欧美高清在线精品一区| 午夜精品亚洲| 亚洲狠狠婷婷| 国产一区二区成人| 欧美日韩在线不卡一区| 久久裸体艺术| 亚洲在线1234| 亚洲人成在线观看一区二区| 久久久www免费人成黑人精品 | 一区在线免费观看| 欧美午夜在线视频| 免费欧美在线| 久久狠狠久久综合桃花| 亚洲午夜免费视频| 最新中文字幕一区二区三区| 久久久久99| 亚洲专区免费| 艳女tv在线观看国产一区| 一区免费观看视频| 国产亚洲精品bv在线观看| 欧美日韩1区2区| 免费亚洲电影| 久久久午夜精品| 欧美一级久久| 亚洲欧美制服另类日韩| 正在播放亚洲| 一本久久综合亚洲鲁鲁五月天| 亚洲高清电影| 亚洲第一在线综合在线| 美日韩丰满少妇在线观看| 欧美一级久久| 亚洲欧美另类久久久精品2019| 9l国产精品久久久久麻豆| 91久久极品少妇xxxxⅹ软件| 在线播放日韩欧美| 激情综合视频| 黄色亚洲精品| 国产主播一区二区三区| 国产日韩综合| 国内精品一区二区三区| 国产色综合天天综合网| 国产视频久久久久| 黄色成人精品网站| 亚洲大片一区二区三区| 亚洲电影自拍| 亚洲精品在线观| 亚洲色诱最新| 性伦欧美刺激片在线观看| 欧美在线观看一区二区三区| 欧美专区在线播放| 久久一区二区三区国产精品| 老司机久久99久久精品播放免费| 久久永久免费| 亚洲国产日韩欧美在线99| 最新日韩中文字幕| 9久re热视频在线精品| 亚洲一区激情| 久久精品视频在线看| 欧美国产精品一区| 欧美视频在线免费| 国产情人综合久久777777| 一区二区亚洲精品| 亚洲精品自在在线观看| 在线亚洲成人| 久久九九精品99国产精品| 欧美freesex交免费视频| 亚洲精品久久久久久一区二区| 亚洲视频高清| 久久精品国产精品| 欧美久色视频| 国产婷婷色一区二区三区在线 | 国产日产欧美a一级在线| 国产有码一区二区| 亚洲国产精品一区二区www| 亚洲一区二区不卡免费| 久久免费视频在线观看| 亚洲精品国产精品久久清纯直播| 亚洲一区二区av电影| 老色鬼久久亚洲一区二区| 国产精品爱久久久久久久| 亚洲大胆在线| 亚洲欧美不卡| 亚洲国产精品第一区二区| 亚欧成人精品| 欧美日韩国产综合视频在线| 精品电影在线观看| 亚洲影院色在线观看免费| 欧美国产日产韩国视频| 亚洲一区欧美一区| 欧美久久久久| 亚洲国产高清在线观看视频| 午夜激情亚洲| av成人免费观看| 欧美激情精品久久久久久黑人 |