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

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片| 久久另类ts人妖一区二区| 激情久久久久久| 裸体丰满少妇做受久久99精品| 欧美一级网站| 激情久久久久久| 欧美高清在线一区| 欧美精品国产一区| 亚洲女人av| 久久国产精品久久精品国产| 国产一区二区三区直播精品电影| 久久一二三四| 欧美韩国在线| 亚洲欧美日韩直播| 久久激情久久| 日韩亚洲一区二区| 亚洲欧美在线一区二区| 在线免费观看日本欧美| 亚洲国产人成综合网站| 欧美日韩一区成人| 久久久久久久久久久久久女国产乱| 久久精品国产77777蜜臀| 亚洲精品视频一区| 亚洲免费婷婷| 亚洲欧洲一区二区天堂久久| 9色porny自拍视频一区二区| 国内精品一区二区| 亚洲美女啪啪| 黄网动漫久久久| 日韩视频一区| 亚洲国产成人精品久久| 亚洲欧美国产日韩中文字幕| 亚洲成色777777女色窝| 亚洲视频高清| 亚洲精一区二区三区| 午夜亚洲激情| av成人天堂| 久热综合在线亚洲精品| 欧美一区三区二区在线观看| 欧美国产视频在线观看| 久久视频在线视频| 国产精品色网| 亚洲欧洲综合另类| 黑丝一区二区三区| 亚洲综合色丁香婷婷六月图片| 亚洲国产综合91精品麻豆| 欧美亚洲视频在线看网址| 一二三区精品| 欧美成人高清| 欧美成人午夜免费视在线看片| 国产女主播一区二区三区| 亚洲精品在线看| 亚洲精品国久久99热| 久久九九免费视频| 久久久噜噜噜久久久| 国产精品自拍视频| 亚洲一区999| 亚洲一区高清| 欧美日韩日本视频| 亚洲精品免费观看| 亚洲精选大片| 欧美精品福利| 亚洲麻豆国产自偷在线| 亚洲美女尤物影院| 欧美精品成人91久久久久久久| 欧美国产日韩a欧美在线观看| 精品av久久久久电影| 欧美在线视频在线播放完整版免费观看 | 中文一区二区在线观看| 亚洲少妇一区| 国产精品v亚洲精品v日韩精品| 亚洲美女一区| 亚洲欧美另类在线| 国产模特精品视频久久久久| 亚洲午夜未删减在线观看| 香蕉成人啪国产精品视频综合网| 国产精品久久久久一区二区三区共| 日韩一级黄色av| 亚洲女女女同性video| 国产免费观看久久| 久久久久国产一区二区三区| 女仆av观看一区| 亚洲精品欧美一区二区三区| 欧美区二区三区| 宅男在线国产精品| 欧美一区二区在线观看| 国产一区二区三区在线观看精品| 久久精品国产99国产精品澳门| 美乳少妇欧美精品| 亚洲肉体裸体xxxx137| 欧美视频在线观看视频极品| 亚洲欧美偷拍卡通变态| 免费不卡欧美自拍视频| 一本色道久久88综合亚洲精品ⅰ | 国产精品一二三| 欧美在线视频二区| 欧美激情一区二区三区在线视频| aⅴ色国产欧美| 国产精品综合| 毛片av中文字幕一区二区| 日韩视频一区| 久久露脸国产精品| 99re视频这里只有精品| 国产亚洲午夜| 欧美乱在线观看| 久久国产黑丝| 日韩视频一区二区三区| 久久夜色精品国产欧美乱| 制服丝袜亚洲播放| 黄色影院成人| 国产精品毛片a∨一区二区三区| 久久免费视频在线| 亚洲一本大道在线| 亚洲高清久久久| 久久久国产91| 亚洲女同性videos| 亚洲精品久久| 极品少妇一区二区三区| 国产精品久久久久久久久久免费| 久久精品主播| 午夜一级久久| 一本大道久久精品懂色aⅴ| 蜜臀久久久99精品久久久久久| 亚洲自拍偷拍福利| 99精品热6080yy久久| 精品粉嫩aⅴ一区二区三区四区| 国产精品第一页第二页第三页| 老司机精品久久| 久久精品国产久精国产爱| 亚洲午夜日本在线观看| 日韩亚洲欧美综合| 亚洲黄色毛片| 欧美激情视频免费观看| 久久精品日产第一区二区| 亚洲午夜在线观看| 在线午夜精品| 一区二区欧美日韩| 亚洲精品小视频在线观看| 亚洲国产三级在线| 亚洲国产一二三| 91久久夜色精品国产网站| 在线成人h网| 伊人婷婷欧美激情| 狠狠色狠狠色综合日日五| 国内精品久久久久久 | 国产日韩av在线播放| 国产精品免费网站| 国产精品入口福利| 国产精品一区在线观看| 国产乱码精品| 国产欧美va欧美va香蕉在| 国产女人水真多18毛片18精品视频| 国产精品豆花视频| 国产欧美 在线欧美| 国产一区二区日韩精品欧美精品| 国产午夜精品一区理论片飘花| 国产美女搞久久| 国外视频精品毛片| 亚洲国产成人av在线| 亚洲国内在线| 中日韩高清电影网| 欧美一区二区成人| 老色鬼久久亚洲一区二区| 免费视频最近日韩| 亚洲日本va午夜在线电影| 在线视频一区二区| 欧美在线视频日韩| 欧美11—12娇小xxxx| 欧美日韩国产精品| 国产精品呻吟| 在线欧美日韩国产| 一区二区三区产品免费精品久久75| 亚洲一级片在线看| 久久婷婷国产麻豆91天堂| 亚洲国产成人久久综合一区| 99在线|亚洲一区二区| 亚洲欧美一区二区三区极速播放 | 99精品欧美一区| 性刺激综合网| 欧美大片91| 国产喷白浆一区二区三区| 亚洲国产精品va在线观看黑人| 亚洲午夜极品| 麻豆亚洲精品| 亚洲天堂av在线免费观看| 久久久久久久精| 国产精品久久久久久影视| 亚洲第一视频| 欧美在线视频一区二区| 欧美激情一区在线| 亚洲男人的天堂在线观看| 免费久久精品视频| 国产精品亚洲第一区在线暖暖韩国| 在线日韩一区二区| 久久精品国产精品亚洲| 亚洲片在线观看| 久久亚洲精品中文字幕冲田杏梨 | 久久www成人_看片免费不卡|