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

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农村| 久久人91精品久久久久久不卡| 在线一区视频| 国产精品视频免费观看| 校园激情久久| 久久精品视频亚洲| 亚洲第一色在线| 亚洲高清电影| 欧美精品一区三区在线观看| 中文亚洲视频在线| 亚洲视频福利| 国产亚洲人成a一在线v站| 久久精品国产一区二区三区免费看| 亚洲欧美国产三级| 激情综合亚洲| 亚洲精品美女久久久久| 欧美涩涩网站| 久热精品视频在线免费观看 | 亚洲私人影吧| 亚洲影视中文字幕| 极品日韩久久| 亚洲免费观看高清完整版在线观看| 欧美日韩在线精品| 久久国产乱子精品免费女| 久久精品首页| 一本久道综合久久精品| 欧美影院午夜播放| 亚洲免费观看高清完整版在线观看熊 | 亚洲欧美三级在线| 久久国产精品亚洲77777| 亚洲精品1区2区| 9人人澡人人爽人人精品| 国外成人在线视频网站| 亚洲高清电影| 国产日韩欧美日韩大片| 欧美大胆人体视频| 国产日韩欧美二区| 亚洲日本中文字幕免费在线不卡| 国产精品国产a| 欧美福利一区二区| 国产视频欧美视频| 99热精品在线| 亚洲精品日韩在线| 久久精品在这里| 亚洲欧美另类中文字幕| 美女视频黄免费的久久| 午夜精品福利一区二区蜜股av| 巨乳诱惑日韩免费av| 欧美一区二区网站| 欧美午夜无遮挡| 亚洲区一区二| 最新日韩中文字幕| 久久久久久久国产| 久久久福利视频| 国产精品乱码| 一本一本久久| 亚洲一区二区免费| 欧美日韩不卡在线| 亚洲国产成人精品久久久国产成人一区| 国产酒店精品激情| 亚洲视频欧美在线| 亚洲一区二区三区在线| 欧美另类在线播放| 亚洲激情社区| 夜夜嗨av色综合久久久综合网| 久久尤物电影视频在线观看| 久久久久久综合网天天| 国产一级久久| 久久av一区二区| 久久只有精品| 亚洲国产成人av在线| 久久久91精品国产一区二区精品| 久久精品女人| 黄色精品一二区| 久久免费视频这里只有精品| 久久夜色精品一区| 在线高清一区| 女主播福利一区| 亚洲国产cao| 一区二区国产日产| 国产精品大全| 欧美一区亚洲二区| 免费视频久久| 日韩视频中午一区| 国产精品国产三级国产专播品爱网| 99视频有精品| 久久不射电影网| 亚洲国产精品国自产拍av秋霞| 免费成人av在线| 日韩写真在线| 欧美中文字幕在线视频| 伊人久久久大香线蕉综合直播| 欧美sm视频| 亚洲一区二区三区四区在线观看 | 亚洲一区二区三区高清 | 国产中文一区| 男人的天堂成人在线| 亚洲日本激情| 欧美伊人久久久久久久久影院| 国模 一区 二区 三区| 免费在线国产精品| 一区二区三区高清在线 | 亚洲剧情一区二区| 国产精品欧美激情| 久久嫩草精品久久久久| 日韩亚洲国产精品| 久久亚洲国产成人| 这里只有视频精品| 国产综合色一区二区三区| 欧美成人资源| 欧美在线视频二区| 亚洲精品综合久久中文字幕| 久久国产精品久久精品国产| 亚洲国产精品久久久久秋霞不卡 | 午夜亚洲视频| 亚洲日韩欧美视频| 久久夜色精品国产欧美乱极品| 99在线精品免费视频九九视| 国产日韩欧美一区二区| 欧美日韩国产首页在线观看| 欧美一区二视频在线免费观看| 91久久精品国产91久久性色| 久久精品中文| 欧美一级视频| 亚洲少妇自拍| 日韩一区二区久久| 亚洲国产精品久久精品怡红院| 国产日韩精品一区二区三区在线| 欧美日韩在线高清| 欧美另类综合| 欧美88av| 美女视频黄免费的久久| 久久国产一区二区三区| 亚洲一区尤物| 亚洲影院一区| 99精品国产福利在线观看免费| 欧美大片网址| 欧美成人午夜激情在线| 久久人人爽人人爽爽久久| 欧美一区2区视频在线观看| 一区二区三区精品视频在线观看| 亚洲国产精品va在线看黑人动漫| 国产一二精品视频| 国产在线国偷精品产拍免费yy| 国产精品久久久久久av福利软件| 欧美日韩国产精品一区| 欧美国产日韩免费| 欧美国产日韩一区二区| 欧美成va人片在线观看| 欧美bbbxxxxx| 欧美剧在线免费观看网站| 欧美精品网站| 欧美日韩一区不卡| 国产精品乱码人人做人人爱| 国产精品高精视频免费| 国产精品欧美久久| 国产日韩欧美麻豆| 狠狠久久五月精品中文字幕| 国产一区二区三区最好精华液| 国产亚洲二区| 亚洲国产高清一区| 日韩视频在线一区| 亚洲网友自拍| 欧美自拍丝袜亚洲| 美女精品网站| 亚洲日本理论电影| 亚洲综合精品四区| 久久人人超碰| 欧美日韩亚洲网| 国产婷婷色一区二区三区四区 | 免费在线日韩av| 欧美日韩三区四区| 国产视频一区二区在线观看 | 欧美高清在线播放| 国产精品成人一区二区三区吃奶| 国产精品永久免费| 亚洲国产cao| 亚洲一区日韩| 久久久水蜜桃| 亚洲精品午夜精品| 欧美一级专区| 欧美欧美午夜aⅴ在线观看| 国产精品视频久久久| 1024亚洲| 亚洲欧美清纯在线制服| 美日韩精品视频免费看| 99riav久久精品riav| 久久久99久久精品女同性| 欧美日韩国产首页| 在线播放精品| 欧美夜福利tv在线| 亚洲精品国产拍免费91在线| 欧美一区二区三区的| 欧美精品在线免费播放| 国产一区二区按摩在线观看| 一区二区三区高清不卡| 免费永久网站黄欧美| 亚洲一区二区三区高清不卡| 免费在线成人av|