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

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| 欧美不卡一区| 99精品视频免费观看| 在线亚洲免费| 久久激情五月激情| 欧美大片免费| 国产精品一区在线观看你懂的| 国产在线拍揄自揄视频不卡99 | 亚洲高清视频一区| 亚洲国产精品一区| 午夜视频一区在线观看| 麻豆91精品| 国产精品久久久久久久久免费桃花| 国产亚洲成av人在线观看导航| 伊人久久亚洲美女图片| 一本色道久久综合亚洲91| 久久久av毛片精品| 妖精成人www高清在线观看| 欧美在线一区二区| 欧美日韩在线免费观看| 狠色狠色综合久久| 亚洲夜晚福利在线观看| 欧美sm视频| 午夜国产精品影院在线观看| 欧美福利专区| 亚洲国产精品t66y| 久久一区国产| 亚洲欧美日韩天堂| 欧美日韩免费高清一区色橹橹| 国产亚洲一级| 欧美一区二区三区在| 亚洲精品国产精品国自产在线| 欧美怡红院视频一区二区三区| 欧美日本视频在线| 亚洲高清一二三区| 久久国产日韩| 亚洲欧美国产日韩天堂区| 男同欧美伦乱| 在线看片欧美| 久久久成人精品| 午夜精品婷婷| 国产精品视频成人| 亚洲深夜av| 亚洲美女电影在线| 欧美人交a欧美精品| 91久久线看在观草草青青| 久久久久.com| 欧美中文字幕在线播放| 国产日韩精品在线| 久久疯狂做爰流白浆xx| 亚洲在线中文字幕| 国产精品伦子伦免费视频| 亚洲一区制服诱惑| 亚洲视频导航| 国产伦精品一区二区三区视频黑人| 亚洲欧美日韩精品综合在线观看 | 亚洲黄色性网站| 久久人人爽人人爽| 在线免费观看日本一区| 免费成人高清| 久久蜜桃资源一区二区老牛 | 国产精品免费看片| 亚洲欧美一区二区三区久久| 这里只有精品电影| 国产精品私房写真福利视频 | 国产精品视频九色porn| 欧美一区久久| 久久精品国亚洲| 伊人久久亚洲热| 亚洲国产高清高潮精品美女| 欧美日本乱大交xxxxx| 亚洲深夜福利网站| 亚洲欧美在线免费观看| 国产一区在线免费观看| 欧美国产大片| 欧美性猛交xxxx乱大交蜜桃| 午夜视频在线观看一区| 久久亚裔精品欧美| 夜夜夜精品看看| 欧美一区91| 亚洲伦理网站| 先锋亚洲精品| 亚洲麻豆国产自偷在线| 亚洲一区二区综合| 亚洲二区在线观看| 中国女人久久久| 在线精品一区| 亚洲私人影院| 亚洲日本成人| 香蕉免费一区二区三区在线观看 | 久久亚洲美女| 亚洲一区二区三区精品在线观看| 欧美亚洲尤物久久| 亚洲精品婷婷| 欧美中文字幕视频| 亚洲伊人第一页| 美女免费视频一区| 久久高清国产| 国产精品白丝黑袜喷水久久久| 免费亚洲电影在线| 国产日韩欧美在线播放| 日韩午夜三级在线| 亚洲国内精品在线| 性伦欧美刺激片在线观看| 亚洲精品乱码久久久久久| 午夜精品视频在线观看| 亚洲天堂av电影| 欧美高清在线精品一区| 美女图片一区二区| 国产日韩欧美中文在线播放| 亚洲卡通欧美制服中文| 亚洲破处大片| 欧美aⅴ一区二区三区视频| 久久国产精彩视频| 国产精品啊v在线| 亚洲精品一区久久久久久| 亚洲欧洲久久| 免费h精品视频在线播放| 久久免费视频在线| 国产午夜精品一区二区三区欧美| 一区二区三区欧美日韩| 一区二区三区欧美激情| 牛人盗摄一区二区三区视频| 久久久精品国产免大香伊 | 欧美性做爰毛片| 亚洲精品偷拍| 日韩亚洲欧美在线观看| 欧美成人一区在线| 亚洲国产成人一区| 一区二区高清在线观看| 欧美日本国产一区| 亚洲欧洲精品一区二区| 一区二区不卡在线视频 午夜欧美不卡'| 麻豆freexxxx性91精品| 女仆av观看一区| 在线精品国产成人综合| 久久婷婷久久| 亚洲成人在线视频播放| 欧美国产大片| 伊人婷婷欧美激情| 噜噜噜噜噜久久久久久91| 欧美暴力喷水在线| 亚洲美女视频在线观看| 欧美性色视频在线| 午夜日韩激情| 免费成人av在线看| 99精品欧美一区二区三区| 欧美体内谢she精2性欧美| 亚洲女女女同性video| 久久综合一区| 一本色道久久综合一区| 国产情侣久久| 免费日韩成人| 亚洲午夜性刺激影院| 久久国产日韩| 亚洲乱码国产乱码精品精| 国产精品二区二区三区| 欧美中日韩免费视频| 亚洲国产高清自拍| 午夜视频在线观看一区| 在线不卡中文字幕| 欧美日韩色一区| 久久av最新网址| 日韩亚洲在线观看| 久久婷婷蜜乳一本欲蜜臀| 亚洲日本中文| 国产精品无码专区在线观看| 久久综合久久综合久久| 中文无字幕一区二区三区| 美女精品网站| 午夜免费电影一区在线观看| 在线观看视频欧美| 国产精品免费久久久久久| 免费观看久久久4p| 亚洲在线中文字幕| 亚洲三级色网| 久热国产精品视频| 亚洲综合色丁香婷婷六月图片| 亚洲电影下载| 国产欧美精品一区aⅴ影院| 欧美激情一区三区| 久久久综合免费视频| 亚洲综合色丁香婷婷六月图片| 亚洲春色另类小说| 久久影视三级福利片| 午夜精品久久久久久久| 野花国产精品入口| 亚洲高清一二三区| 国模套图日韩精品一区二区| 国产精品日本一区二区| 欧美日韩高清在线观看|