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

            oyjpArt ACM/ICPC算法程序設(shè)計(jì)空間

            // I am new in programming, welcome to my blog
            I am oyjpart(alpc12, 四城)
            posts - 224, comments - 694, trackbacks - 0, articles - 6
            前面做的那道Bridging?Signals是有技巧性的題目 因?yàn)轭}目要求o(n*logn)的復(fù)雜度
            剛才又做了一道The Tower of Babylon 題目不難 但是堪稱經(jīng)典啦

            簡(jiǎn)述: 有N種石頭(每種數(shù)量無(wú)限)題目給出每種的長(zhǎng)寬高 先要求將其按底面積遞減的順序從下往上堆(注意是嚴(yán)格遞減 對(duì)應(yīng)邊相等不算) 問(wèn)最多可以堆多高?

            分析:首先我想的是處理底面積的時(shí)候可能要分情況討論,但是比較復(fù)雜。于是干脆將每塊石頭變成3塊(這樣就可以得到石頭的真正總數(shù)了)。block代表所有石頭 有3個(gè)成員x,y,z.

            ?然后將其按照底面積大小從大到小排序。建立一個(gè)數(shù)組h[],h[i]記錄的是當(dāng)前石頭作為頂上石頭時(shí)候的總高度。于是狀態(tài)轉(zhuǎn)移方程為 h[i] = max {h[j]+block[i].z)。輸出最大的height[i]就可以了

            呵呵 做完之后不知怎么覺(jué)得好爽啊~~

            Feedback

            # re: 今天我做的一道經(jīng)典動(dòng)歸題The Tower of Babylon   回復(fù)  更多評(píng)論   

            2006-08-09 08:57 by cmdn
            很羨慕你的說(shuō),大學(xué)里能夠這么有耐心的研究算法。我一直在考慮我能夠在計(jì)算機(jī)領(lǐng)域內(nèi)發(fā)展到什么層次?恐怕這些我不感興趣的算法以后會(huì)成為我很大的阻礙阿 !

            # re: 今天我做的一道經(jīng)典動(dòng)歸題The Tower of Babylon   回復(fù)  更多評(píng)論   

            2006-08-09 11:03 by sicheng
            是自從接觸ACM以來(lái)才知道自己原來(lái)水平有多菜~~(呵呵) 后來(lái)才知道原來(lái)自己與別人的差距有多大啊~~ 從最簡(jiǎn)單的算法開(kāi)始認(rèn)認(rèn)真真學(xué) 爭(zhēng)取早日走出菜鳥(niǎo)的圈圈

            # re: 今天我做的一道經(jīng)典動(dòng)歸題The Tower of Babylon   回復(fù)  更多評(píng)論   

            2006-08-09 18:14 by SoRoMan
            感覺(jué)就是個(gè)插入排序問(wèn)題,其插入排序?qū)崿F(xiàn)見(jiàn)http://www.shnenglu.com/SoRoMan/archive/2006/08/09/11053.html

            # re: 今天我做的一道經(jīng)典動(dòng)歸題The Tower of Babylon   回復(fù)  更多評(píng)論   

            2006-08-09 19:11 by sicheng
            非常感謝SoRoMan對(duì)這道題的關(guān)注,甚至還為此寫出了完整的程序。
            程序?qū)懙暮芷粒浅8兄x。
            由于本人的疏忽 題目描述地不是很清楚,所以特此也把整個(gè)原題貼出來(lái)(由于已經(jīng)寫了簡(jiǎn)述,故不再翻譯原題(呵呵,實(shí)際上是沒(méi)那英文水準(zhǔn)~~-_-))

            The Tower of Babylon
            Time Limit:1000MS Memory Limit:65536K
            Total Submit:230 Accepted:147

            Description
            Perhaps you have heard of the legend of the Tower of Babylon. Nowadays many details of this tale have been forgotten. So now, in line with the educational nature of this contest, we will tell you the whole story:
            The babylonians had n types of blocks, and an unlimited supply of blocks of each type. Each type-i block was a rectangular solid with linear dimensions (xi, yi, zi). A block could be reoriented so that any two of its three dimensions determined the dimensions of the base and the other dimension was the height.
            They wanted to construct the tallest tower possible by stacking blocks. The problem was that, in building a tower, one block could only be placed on top of another block as long as the two base dimensions of the upper block were both strictly smaller than the corresponding base dimensions of the lower block. This meant, for example, that blocks oriented to have equal-sized bases couldn't be stacked.

            Your job is to write a program that determines the height of the tallest tower the babylonians can build with a given set of blocks.

            Input
            The input will contain one or more test cases. The first line of each test case contains an integer n,
            representing the number of different blocks in the following data set. The maximum value for n is 30.
            Each of the next n lines contains three integers representing the values xi, yi and zi.
            Input is terminated by a value of zero (0) for n.

            Output
            For each test case, print one line containing the case number (they are numbered sequentially starting from 1) and the height of the tallest possible tower in the format "Case case: maximum height = height"

            Sample Input


            1
            10 20 30
            2
            6 8 10
            5 5 5
            7
            1 1 1
            2 2 2
            3 3 3
            4 4 4
            5 5 5
            6 6 6
            7 7 7
            5
            31 41 59
            26 53 58
            97 93 23
            84 62 64
            33 83 27
            0


            Sample Output


            Case 1: maximum height = 40
            Case 2: maximum height = 21
            Case 3: maximum height = 28
            Case 4: maximum height = 342


            Source
            Ulm Local 1996

            # re: 今天我做的一道經(jīng)典動(dòng)歸題The Tower of Babylon   回復(fù)  更多評(píng)論   

            2006-08-10 02:45 by
            我也跑去做做:)

            # re: 今天我做的一道經(jīng)典動(dòng)歸題The Tower of Babylon   回復(fù)  更多評(píng)論   

            2007-07-29 21:23 by keky
            非常感謝師兄的提示,我DP一貫很差,今個(gè)有過(guò)了一個(gè)。。。受益匪淺!TH

            # re: 今天我做的一道經(jīng)典動(dòng)歸題The Tower of Babylon [未登錄](méi)  回復(fù)  更多評(píng)論   

            2007-07-30 15:35 by oyjpArt
            師兄?你是?

            # re: 今天我做的一道經(jīng)典動(dòng)歸題The Tower of Babylon   回復(fù)  更多評(píng)論   

            2009-04-30 14:32 by 尖尖角
            lz的沒(méi)看太明白呢,不過(guò)我用深度優(yōu)先搜索的方法做出來(lái)了哦
            算法分析如下:
            1) 將n個(gè)石塊存入blocks[3n]中(如lz一樣把每一塊分成三塊,但不用求面積,也不用排序)
            2) 構(gòu)建blocks的有向鄰接表adj。(eg blocks[i]--> block[j] 的條件是 i的底部長(zhǎng)寬都比j的小 即,嚴(yán)格小于)
            3) 深度優(yōu)先搜索整個(gè)鄰接表。并用一個(gè)數(shù)組height[n]記錄以每一個(gè)節(jié)點(diǎn)為最底層塊的時(shí)候的最大高度
            4) 遍歷height[n],值最大的那個(gè)就是所求的最大高度了。

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            精品无码久久久久久尤物| 久久久精品久久久久久| 午夜视频久久久久一区 | 久久精品三级视频| 亚洲精品国产自在久久| 久久精品国产久精国产| 亚洲国产婷婷香蕉久久久久久| 久久精品国产亚洲av麻豆蜜芽| 999久久久无码国产精品| 久久久久久伊人高潮影院| 久久精品草草草| 亚洲狠狠婷婷综合久久久久 | 久久精品?ⅴ无码中文字幕| 久久久精品久久久久久 | 久久国产免费观看精品3| 亚洲国产成人精品久久久国产成人一区二区三区综 | 久久er国产精品免费观看2| 看全色黄大色大片免费久久久| 热99re久久国超精品首页| 狠狠色丁香久久婷婷综合_中| 久久久精品无码专区不卡| 久久国产精品无码一区二区三区| 亚洲欧美另类日本久久国产真实乱对白 | 亚洲AV无码久久精品蜜桃| 亚州日韩精品专区久久久| 国产精品99久久久久久董美香 | 久久精品视屏| 91精品国产综合久久四虎久久无码一级 | 亚洲精品蜜桃久久久久久| 伊人久久大香线蕉精品不卡 | 日日狠狠久久偷偷色综合96蜜桃| 日韩亚洲欧美久久久www综合网| 性色欲网站人妻丰满中文久久不卡| 久久久久99这里有精品10| 亚洲午夜久久久久久久久久| 亚洲AV无码一区东京热久久 | 日韩欧美亚洲综合久久影院Ds| 久久996热精品xxxx| 日韩精品久久久久久久电影| 2020国产成人久久精品| 亚洲国产精品无码久久久蜜芽 |