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

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 閱讀(129) 評論(0)  編輯 收藏 引用
<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>
            夜夜夜久久久| 欧美自拍偷拍午夜视频| 欧美—级高清免费播放| 亚洲激情网址| 欧美激情视频网站| 欧美国产大片| 亚洲欧美国产视频| 欧美一区日本一区韩国一区| 好看的日韩av电影| 亚洲高清不卡| 欧美高清不卡在线| 一本一本久久| 亚洲男人的天堂在线| 国产欧美日韩精品专区| 久久久久久亚洲精品杨幂换脸| 久久精品国产亚洲a| 亚洲黄色视屏| 一区二区三区产品免费精品久久75 | 欧美激情成人在线| 欧美激情中文不卡| 亚洲一区二区三| 欧美专区在线播放| 亚洲精品日日夜夜| 亚洲视频免费看| 国模一区二区三区| 亚洲精品久久在线| 国产日韩欧美综合一区| 亚洲成人在线视频播放| 欧美精品日韩| 久久婷婷丁香| 国产精品国产三级国产普通话蜜臀| 久久疯狂做爰流白浆xx| 欧美高清视频在线观看| 久久精品卡一| 欧美日韩精选| 欧美顶级少妇做爰| 国产亚洲精品久久久| 亚洲欧洲在线免费| 激情欧美一区二区| 亚洲已满18点击进入久久| 亚洲精品国精品久久99热| 性亚洲最疯狂xxxx高清| 中文日韩在线| 免费日韩成人| 免费成人性网站| 国产区日韩欧美| 一区二区三区四区五区视频| 亚洲国产免费看| 久久久www| 欧美一区二区| 国产精品久久久久秋霞鲁丝| 亚洲精品四区| 日韩午夜在线视频| 欧美国产一区在线| 亚洲高清一区二区三区| 在线看片一区| 久久久久99| 久久亚洲国产精品一区二区| 国产日韩欧美在线播放不卡| 亚洲一区在线播放| 亚洲一区二区精品在线| 欧美色综合网| 一区二区高清| 亚洲欧美不卡| 国产精品一区一区| 亚洲免费伊人电影在线观看av| 亚洲素人一区二区| 欧美日一区二区三区在线观看国产免| 亚洲国产精品电影| 一本久久知道综合久久| 欧美日韩成人免费| 99ri日韩精品视频| 亚洲欧美另类综合偷拍| 国产欧美日本| 久久久蜜臀国产一区二区| 久久亚洲私人国产精品va媚药| 国产综合久久久久久| 久久久久久噜噜噜久久久精品 | 亚洲高清久久网| 欧美a一区二区| 亚洲裸体在线观看| 亚洲欧美一区二区在线观看| 国产乱码精品一区二区三区不卡 | 欧美日韩亚洲三区| 亚洲——在线| 玖玖在线精品| 99精品热6080yy久久| 国产精品乱码久久久久久| 欧美一区1区三区3区公司| 牛牛国产精品| 在线综合视频| 国产综合色精品一区二区三区 | 99成人免费视频| 久久精品一区二区三区中文字幕| 在线看片日韩| 国产精品久久99| 久久久久久一区二区| 日韩天天综合| 久久久国产成人精品| 亚洲巨乳在线| 国产亚洲综合在线| 欧美精品三级日韩久久| 午夜在线a亚洲v天堂网2018| 亚洲国产精选| 久久久久.com| 在线中文字幕日韩| 亚洲风情亚aⅴ在线发布| 欧美视频在线免费看| 久久久国产精品一区二区中文 | 亚洲欧美在线磁力| 亚洲激情在线| 久久三级福利| 亚洲欧美精品在线| 亚洲精品老司机| 国产啪精品视频| 欧美日韩在线第一页| 久久久久在线| 午夜视频久久久久久| 一本在线高清不卡dvd | 午夜精品成人在线| 亚洲最黄网站| 亚洲国产视频a| 韩日欧美一区| 国产日韩欧美夫妻视频在线观看| 欧美日韩国产123| 免费在线成人av| 久久网站免费| 久久久久国产精品www| 亚洲欧美成人一区二区在线电影 | 亚洲精品国产视频| 欧美激情免费在线| 暖暖成人免费视频| 久久亚洲视频| 老牛嫩草一区二区三区日本| 久久国产日韩欧美| 欧美专区亚洲专区| 欧美亚洲专区| 欧美亚洲综合网| 欧美一区二区三区另类 | 91久久精品国产| 亚洲国产精品电影| 亚洲国产精品福利| 亚洲福利久久| 亚洲国产成人av好男人在线观看| 激情久久久久| 一区二区三区在线免费播放| 红桃视频成人| 最近中文字幕mv在线一区二区三区四区| 禁断一区二区三区在线| 一区二区三区无毛| 亚洲国产mv| 99热在这里有精品免费| 一区二区三区福利| 亚洲五月六月| 欧美一区免费| 麻豆freexxxx性91精品| 欧美电影在线观看| 亚洲肉体裸体xxxx137| 一区二区三区高清视频在线观看| 亚洲素人在线| 欧美亚洲日本国产| 老司机精品视频一区二区三区| 久久久久这里只有精品| 欧美激情国产日韩精品一区18| 欧美日韩亚洲精品内裤| 国产伦精品一区二区三区四区免费| 国产一区二区三区在线观看视频 | 久久综合九色综合欧美就去吻 | 裸体一区二区| 亚洲精品美女在线观看| 亚洲在线一区| 久久亚洲精品中文字幕冲田杏梨| 欧美极品在线播放| 国产精品天天摸av网| 狠狠色伊人亚洲综合网站色| 亚洲经典视频在线观看| 亚洲欧美日韩国产综合| 欧美暴力喷水在线| 一区二区三区日韩欧美| 欧美中文在线免费| 欧美日韩福利视频| 黄色一区二区三区四区| 在线视频欧美日韩精品| 久久一区二区视频| 一本大道久久a久久精品综合| 久久国产66| 国产精品久久久久久久久久直播| 极品少妇一区二区三区精品视频| 亚洲视频免费在线| 欧美成人精品一区二区| 亚洲综合清纯丝袜自拍| 欧美精品福利视频| 激情懂色av一区av二区av| 亚洲综合国产精品| 亚洲第一网站免费视频| 欧美一区二区三区精品电影| 欧美婷婷久久| 亚洲九九爱视频| 欧美大片18| 欧美在线3区|