• <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

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久久久波多野结衣高潮| 日韩精品久久无码中文字幕| 精品国产一区二区三区久久久狼| 久久综合给合久久狠狠狠97色69| 久久综合香蕉国产蜜臀AV| 久久久久国产精品| 亚洲欧美国产精品专区久久| 伊人久久综合精品无码AV专区| 久久久久久国产精品无码超碰| 久久93精品国产91久久综合| 亚洲香蕉网久久综合影视| 久久AAAA片一区二区| 久久久久久国产精品免费无码| 久久综合给合综合久久| 国产精品久久久久9999高清| 伊人久久精品影院| 一本大道加勒比久久综合| 人妻少妇久久中文字幕一区二区 | 午夜精品久久久久久| 国产精品久久亚洲不卡动漫| 久久只有这精品99| 久久精品亚洲男人的天堂| 精品亚洲综合久久中文字幕| 亚洲午夜无码久久久久| 久久无码中文字幕东京热| 青青久久精品国产免费看| 成人a毛片久久免费播放| 久久久久亚洲Av无码专| 国产偷久久久精品专区| 亚洲国产精品无码久久青草| 久久精品国产亚洲精品| 91久久成人免费| 777久久精品一区二区三区无码| 看久久久久久a级毛片| 欧美丰满熟妇BBB久久久| 狠狠色婷婷久久综合频道日韩 | 狠色狠色狠狠色综合久久| 男女久久久国产一区二区三区| 色天使久久综合网天天| 热久久视久久精品18| 久久这里都是精品|