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

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,當(dāng)然KM也能正確求解,暴搜更是無敵!
現(xiàn)在這是一道變形的TSP,搞清題目意思就很容易求解,不幸的是在統(tǒng)計路徑的時候,我居然
腦殘的sum++,而應(yīng)該是sum+=dpways[(1<<n)-1][i][j];因此白白的貢獻了N個WA,
腦殘人士!請見諒!
代碼很慢,735ms,不貼了!
-------------------------------------------------------------------------------------------
上課去了!!!
posted on 2009-03-26 09:56 KNIGHT 閱讀(134) 評論(0)  編輯 收藏 引用

只有注冊用戶登錄后才能發(fā)表評論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


<2009年3月>
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234

常用鏈接

留言簿(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>
            国产精品区一区二区三| 久久国内精品视频| 中文在线不卡视频| 国产精品一区二区久久久久| 欧美影片第一页| 久久久久久久久一区二区| 亚洲国产日韩在线一区模特| 91久久久久久国产精品| 嫩草影视亚洲| 亚洲小说欧美另类婷婷| 午夜精品一区二区三区四区| 亚洲电影在线观看| 亚洲肉体裸体xxxx137| 国产精品老牛| 久久精品国产综合| 久久三级视频| 亚洲一区二区三区在线| 亚洲综合首页| 亚洲国内精品在线| 在线综合+亚洲+欧美中文字幕| 国产视频一区欧美| 亚洲国产清纯| 国产精品亚洲综合久久| 欧美成人激情视频| 欧美日韩一区二区三区视频| 国产精品久久久久久久久借妻| 久久久www| 欧美精品亚洲二区| 欧美在线视频一区| 欧美电影免费观看| 久久gogo国模啪啪人体图| 久久人人97超碰精品888| 久久久久久综合| 亚洲午夜一区二区| 久久综合国产精品台湾中文娱乐网| 一区二区三区高清在线| 久久精品国产96久久久香蕉| 一本色道久久综合亚洲精品小说| 欧美与黑人午夜性猛交久久久| 日韩一级视频免费观看在线| 久久高清免费观看| 亚洲手机在线| 美女网站久久| 久久国产主播| 国产精品扒开腿爽爽爽视频| 欧美国产日韩一二三区| 国产欧美成人| 亚洲乱码日产精品bd| 伊人久久久大香线蕉综合直播| 噜噜噜91成人网| 国产精品日韩一区二区| 亚洲欧洲精品一区二区精品久久久| 国产午夜精品一区二区三区视频 | 国产欧美一区二区精品性色| 蜜桃伊人久久| 国产伦精品一区二区三区在线观看| 亚洲国产日韩欧美| 国内一区二区三区| 亚洲一区二区日本| 99精品国产在热久久| 久久亚洲午夜电影| 久久国产手机看片| 国产精品成人观看视频国产奇米| 亚洲高清在线观看| 激情综合久久| 新狼窝色av性久久久久久| 亚洲午夜久久久久久尤物| 欧美 日韩 国产 一区| 久久综合国产精品| 国产日韩av在线播放| 在线亚洲激情| 一区二区三区av| 亚洲视频中文| 一区二区三区日韩在线观看| 免费成人高清在线视频| 久久综合九色九九| 国产日韩欧美麻豆| 亚洲一区影院| 亚洲私人影院| 欧美成人免费在线| 久久久久久亚洲精品杨幂换脸 | 亚洲精品欧美| 亚洲激情视频网站| 久久久噜噜噜久噜久久| 久久久久久一区二区三区| 国产麻豆综合| 亚洲欧美日韩在线| 亚洲欧美中文在线视频| 国产精品高潮久久| 一本色道综合亚洲| 亚洲午夜精品17c| 欧美日韩视频在线| 亚洲美女一区| 亚洲图中文字幕| 欧美日韩一区在线视频| 99xxxx成人网| 亚洲一区二区三区四区五区午夜| 欧美日韩午夜视频在线观看| 亚洲精品综合在线| 亚洲深夜福利网站| 欧美午夜寂寞影院| 中文av一区二区| 国产综合久久| 久久精品夜色噜噜亚洲aⅴ| 久久婷婷一区| 影音先锋中文字幕一区| 久久亚洲一区二区| 欧美好吊妞视频| 亚洲伦理在线免费看| 欧美日本高清视频| aa成人免费视频| 国产精品美女主播| 亚洲国产裸拍裸体视频在线观看乱了| 亚洲国产日韩综合一区| 欧美—级在线免费片| 日韩视频在线免费| 午夜亚洲激情| 国产一区清纯| 久久综合一区| 亚洲欧洲一区二区三区在线观看| 一区二区三区久久久| 欧美香蕉视频| 小处雏高清一区二区三区| 久久久久综合一区二区三区| 在线欧美小视频| 欧美激情按摩| 亚洲午夜成aⅴ人片| 久久精品在线播放| …久久精品99久久香蕉国产 | 亚洲欧美日韩另类精品一区二区三区| 国产精品午夜在线观看| 欧美专区一区二区三区| 欧美高清视频在线| 一区二区久久久久久| 久久久久国产精品www| 欧美激情一区二区在线| 亚洲视频在线视频| 国产午夜亚洲精品不卡| 久久夜色精品一区| 99pao成人国产永久免费视频| 欧美亚洲一级| 亚洲国产福利在线| 欧美日韩另类国产亚洲欧美一级| 亚洲综合第一| 欧美国产精品v| 欧美xx视频| 一区二区精品国产| 久久亚洲春色中文字幕| 日韩一级片网址| 国产手机视频一区二区| 欧美成人资源| 亚洲欧美精品一区| 欧美激情久久久久| 亚洲欧美日韩视频一区| 影音先锋久久| 欧美午夜精品久久久| 久久久久久久久蜜桃| 一区二区三区四区五区视频 | 国产乱人伦精品一区二区 | 欧美精品三区| 欧美一区2区视频在线观看 | 亚洲一区欧美二区| 狠狠88综合久久久久综合网| 欧美精品乱人伦久久久久久| 小嫩嫩精品导航| 亚洲日本成人女熟在线观看| 欧美综合国产| 9色porny自拍视频一区二区| 国产一区二区高清| 欧美日韩一区二区三| 久久久久国产精品一区二区| 一本久道久久综合婷婷鲸鱼| 国产精品乱码人人做人人爱| 美玉足脚交一区二区三区图片| 亚洲性线免费观看视频成熟| 亚洲第一主播视频| 欧美在线观看网址综合| 日韩视频在线一区二区| 国内精品久久久久久久影视麻豆 | 欧美在线观看一区| 日韩天天综合| 欧美国产欧美亚洲国产日韩mv天天看完整| 午夜宅男欧美| 99亚洲伊人久久精品影院红桃| 国内精品久久久| 国产精品久久久久永久免费观看| 欧美chengren| 久久久精品日韩欧美| 亚洲免费在线电影| 亚洲美女一区| 亚洲国产精品久久久久婷婷老年| 久久久久久久综合| 亚洲欧美激情诱惑| 国产视频在线观看一区 | 亚洲毛片一区二区| 欧美第十八页| 久久综合狠狠综合久久综青草| 亚洲欧美久久久久一区二区三区| 亚洲乱码国产乱码精品精可以看| 一区二区在线不卡|