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

            Description

            The cows have revised their game of leapcow. They now play in the middle of a huge pasture upon which they have marked a grid that bears a remarkable resemblance to a chessboard of N rows and N columns (3 <= N <= 365).

            Here's how they set up the board for the new leapcow game:

            * First, the cows obtain N x N squares of paper. They write the integers from 1 through N x N, one number on each piece of paper.

            * Second, the 'number cow' places the papers on the N x N squares in an order of her choosing.

            Each of the remaining cows then tries to maximize her score in the game.

            * First, she chooses a starting square and notes its number.

            * Then, she makes a 'knight' move (like the knight on a chess board) to a square with a higher number. If she's particularly strong, she leaps to the that square; otherwise she walks.

            * She continues to make 'knight' moves to higher numbered squares until no more moves are possible.

            Each square visited by the 'knight' earns the competitor a single point. The cow with the most points wins the game.

            Help the cows figure out the best possible way to play the game.

            Input

            * Line 1: A single integer: the size of the board

            * Lines 2.. ...: These lines contain space-separated integers that tell the contents of the chessboard. The first set of lines (starting at the second line of the input file) represents the first row on the chessboard; the next set of lines represents the next row, and so on. To keep the input lines of reasonable length, when N > 15, a row is broken into successive lines of 15 numbers and a potentially shorter line to finish up a row. Each new row begins on its own line.

            Output

            * Line 1: A single integer that is the winning cow's score; call it W.

            * Lines 2..W+1: Output, one per line, the integers that are the starting square, the next square the winning cow visits, and so on through the last square. If a winning cow can choose more than one path, show the path that would be the 'smallest' if the paths were sorted by comparing their respective 'square numbers'.

            Sample Input

            4
            1 3 2 16
            4 10 6 7
            8 11 5 12
            9 13 14 15

            Sample Output

            72459101213
            本以為最長上升子序列,沒錯,最長的步數(shù)對了,但是因為路徑更新有無,所以還是一直Wrong Answer。。。。無語

            
            

             

            代碼AC后更新

            posted on 2008-12-23 21:52 KNIGHT 閱讀(384) 評論(2)  編輯 收藏 引用

            FeedBack:
            # re: poj 2111 Millenium Leapcow
            2008-12-23 23:22 | Knight
            如果你能接受這個
            3160K 1047MS C++ 1547B
            真的很煩,居然1047ms一般都是200ms左右我居然這么多,暈
            思路還是最長上升子序列
            不過更新路徑的函數(shù)代碼如下
            int cmp(int a,int b)
            {
            if(pre[a]==a)
            {
            if(a>b)return 1;
            else if(a==b)return 0;
            else return -1;
            }
            else
            {
            int t=cmp(pre[a],pre[b]);
            if(t==0)
            {
            if(a>b)return 1;
            else if(a==b)return 0;
            else return -1;
            }
            else return t;
            }
            }
            ********************************
            即如果路徑長度相同的話,就執(zhí)行cmp從而判斷字典序!更新字典序!很浪費時間!
            ********************************  回復(fù)  更多評論
              
            # re: poj 2111 Millenium Leapcow
            2008-12-24 12:43 | Knight
            魷魚大牛的思路
            從n*n開始搜索到1結(jié)束DP更新路徑
            排名20 3160K 157MS C++ 1228B
            還行經(jīng)典代碼如下:
            for(i=M;i>=1;i--)
            {
            for(j=0;j<8;j++)
            {
            int x=num[i].x+dir[j][0];
            int y=num[i].y+dir[j][1];
            if(OK(x,y,i))
            {
            if(num[i].max+1>num[map[x][y]].max)
            {
            num[map[x][y]].max=num[i].max+1;
            pre[map[x][y]]=i;
            }
            else if(num[i].max+1==num[map[x][y]].max&&i<pre[map[x][y]])
            pre[map[x][y]]=i;
            }
            }
            if(MAX<=num[i].max)
            {
            MAX=num[i].max;
            sign=i;
            }
            }  回復(fù)  更多評論
              

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


            <2009年3月>
            22232425262728
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久男人Av资源网站无码软件| 精品久久久久久无码不卡| 亚洲中文字幕久久精品无码喷水| 99久久做夜夜爱天天做精品| 亚洲中文字幕久久精品无码APP| 91精品国产9l久久久久| 久久久黄片| 亚洲国产精品久久久天堂| 伊人久久精品线影院| 精品熟女少妇AV免费久久| 国产亚洲综合久久系列| 色播久久人人爽人人爽人人片aV| 久久久久亚洲AV无码永不| 久久精品国产精品亜洲毛片| 日韩精品久久无码人妻中文字幕 | 97精品伊人久久久大香线蕉 | 色综合久久天天综合| 国产成人精品综合久久久久| 久久国产精品国产自线拍免费| 亚洲欧美另类日本久久国产真实乱对白| 久久婷婷成人综合色综合| 97精品伊人久久大香线蕉| 精品久久久久一区二区三区| 精品熟女少妇AV免费久久| 欧美黑人激情性久久| 亚洲国产成人精品久久久国产成人一区二区三区综 | 亚洲国产一成久久精品国产成人综合| 久久亚洲春色中文字幕久久久| 漂亮人妻被中出中文字幕久久| 国产精品狼人久久久久影院 | 久久99精品久久久大学生| 婷婷久久综合九色综合九七| 久久久久久国产精品免费免费 | 久久天天躁夜夜躁狠狠躁2022| 精品久久国产一区二区三区香蕉 | 蜜桃麻豆WWW久久囤产精品| 久久99国产精品成人欧美| 久久国产精品免费| 久久最新免费视频| 午夜精品久久久久9999高清| 色综合久久88色综合天天 |