• <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>
            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 閱讀(124) 評論(0)  編輯 收藏 引用
            <2009年3月>
            22232425262728
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            亚洲欧美一级久久精品| 久久久精品人妻一区二区三区四 | 91精品国产色综合久久| 秋霞久久国产精品电影院| 久久午夜综合久久| 久久棈精品久久久久久噜噜| 国产精品成人精品久久久| 精产国品久久一二三产区区别| 精品久久无码中文字幕| 亚洲欧美久久久久9999 | 久久久久久免费视频| 7777久久亚洲中文字幕| 久久无码AV中文出轨人妻| 久久伊人精品青青草原高清| 久久国语露脸国产精品电影| 久久青青草原国产精品免费 | 久久人做人爽一区二区三区| 国产三级观看久久| 97久久超碰成人精品网站| 99久久精品国产一区二区| 人妻系列无码专区久久五月天| 996久久国产精品线观看| 精品久久久无码21p发布| 久久亚洲国产精品五月天婷| 国产福利电影一区二区三区久久久久成人精品综合 | 精品99久久aaa一级毛片| 97久久超碰国产精品旧版| 久久精品国产亚洲AV不卡| 精品熟女少妇aⅴ免费久久| 国产高清国内精品福利99久久| 久久本道伊人久久| 久久久久久久99精品免费观看| 国产成人精品综合久久久| 伊人久久精品无码二区麻豆| 久久天天躁狠狠躁夜夜不卡 | 久久强奷乱码老熟女| 无夜精品久久久久久| 久久国内免费视频| 久久久久久综合网天天| 狠狠色噜噜色狠狠狠综合久久| 久久天天躁狠狠躁夜夜96流白浆|