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

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 閱讀(391) 評論(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年4月>
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

常用鏈接

留言簿(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>
            亚洲国产美女| 久久激情一区| 性欧美办公室18xxxxhd| 日韩亚洲欧美精品| 亚洲欧洲日韩综合二区| 亚洲激情黄色| 亚洲午夜高清视频| 男女视频一区二区| 欧美偷拍一区二区| 欧美视频一二三区| 国产欧美日本一区视频| 国产真实乱子伦精品视频| 国产午夜亚洲精品理论片色戒| 国产午夜精品视频免费不卡69堂| 国产夜色精品一区二区av| 精品成人国产在线观看男人呻吟| 国产欧美一区二区精品秋霞影院| 国产精品香蕉在线观看| 国产在线观看一区| 亚洲国产另类久久精品| 亚洲一级黄色av| 欧美影院成人| 老司机免费视频久久| 亚洲欧洲日本专区| 亚洲国产三级网| 午夜免费电影一区在线观看| 久久久久久欧美| 欧美日韩网站| 韩国美女久久| 亚洲视频成人| 久久国产一区二区三区| 亚洲靠逼com| 日韩一二在线观看| 国产精品国产三级国产普通话三级 | 国产精品国色综合久久| 好吊成人免视频| 一本色道久久88精品综合| 久久久伊人欧美| 亚洲视频在线观看免费| 欧美jizz19性欧美| 国产婷婷成人久久av免费高清 | 中文一区字幕| 免费高清在线一区| 一本色道久久综合狠狠躁篇怎么玩 | 一区二区欧美在线观看| 久久精品一区二区| 国产精品久久久久毛片大屁完整版| 尹人成人综合网| 久久国产精品色婷婷| 日韩香蕉视频| 欧美精品福利| 亚洲黑丝在线| 美女视频黄a大片欧美| 午夜免费久久久久| 国产精品日韩精品| 亚洲自拍三区| 亚洲一卡久久| 国产精品私房写真福利视频| 一区二区三区|亚洲午夜| 性伦欧美刺激片在线观看| 亚洲精品中文在线| 欧美激情精品久久久久久变态 | 国产欧美在线观看一区| 亚洲欧美激情一区| 在线视频欧美精品| 国产精品入口麻豆原神| 性色av香蕉一区二区| 亚洲一区二区三区精品在线观看 | 亚洲人成毛片在线播放女女| 久热国产精品| 久久亚洲欧美| 亚洲精品男同| 99精品欧美一区二区三区| 欧美日韩高清区| 亚洲午夜视频| 玖玖精品视频| 久久人体大胆视频| 在线欧美日韩精品| 欧美成人一品| 欧美精品日韩综合在线| 一区二区三区精品| 亚洲一二三区视频在线观看| 欧美性一二三区| 欧美日韩中字| 亚洲欧美日韩精品久久奇米色影视 | 久久精品国产一区二区三| 狠狠色丁香久久婷婷综合_中| 久久人人爽人人| 免费日韩成人| 亚洲一区二区三区涩| 欧美大胆成人| 久久一区国产| 亚洲午夜激情| 欧美在线视频免费| 亚洲人成网站在线观看播放| 日韩一级免费| 一区二区三区在线不卡| 亚洲经典自拍| 国产精品亚洲人在线观看| 麻豆精品一区二区综合av| 欧美激情成人在线| 久久成人一区| 欧美人与性动交cc0o| 久久国产手机看片| 欧美日韩国产高清| 久久亚洲一区| 国产精品白丝黑袜喷水久久久 | 在线日韩av永久免费观看| 亚洲欧洲日产国码二区| 国产欧美一区二区在线观看| 亚洲国产日韩在线一区模特| 国产亚洲精品久久久久婷婷瑜伽 | 亚洲作爱视频| 亚洲国产高潮在线观看| 亚洲一区国产| 99国产精品久久久久久久| 久久精品国产亚洲精品| 亚洲自拍偷拍视频| 免费观看一区| 久久午夜激情| 国产精品亚洲综合一区在线观看| 亚洲国产精品电影| 国产一区二区三区视频在线观看| 一区二区三区日韩欧美精品| 亚洲精品欧洲精品| 六月婷婷久久| 嫩草伊人久久精品少妇av杨幂| 国产精品h在线观看| 亚洲激精日韩激精欧美精品| 激情婷婷欧美| 久久精品综合| 合欧美一区二区三区| 欧美日本不卡| 亚洲黄色毛片| 久久av红桃一区二区小说| 日韩视频国产视频| 欧美1区免费| 免费看精品久久片| 欧美日韩在线不卡一区| 亚洲国产精品成人综合| 91久久精品国产91性色| 亚洲欧美综合一区| 一本到高清视频免费精品| 欧美—级a级欧美特级ar全黄| 99精品视频一区| 久久久免费精品视频| 免费人成网站在线观看欧美高清 | 国产精品免费看| 一区二区三区精密机械公司| 亚洲一卡久久| 国产精品视频久久久| 午夜在线一区二区| 久久视频这里只有精品| 伊人久久大香线蕉综合热线| 久久夜精品va视频免费观看| 欧美黄色大片网站| 中日韩美女免费视频网址在线观看 | 亚洲欧美视频一区二区三区| 国产精品久久久久久久久借妻| 亚洲一区三区视频在线观看| 久久狠狠亚洲综合| 在线欧美日韩国产| 欧美精品久久久久久久免费观看 | 欧美成人中文字幕在线| 亚洲国产老妈| 国产精品国产三级国产aⅴ浪潮| 久久xxxx| 亚洲精品免费看| 欧美一区二区三区视频免费播放| 国内精品久久久久影院优| 蜜桃av久久久亚洲精品| 亚洲桃花岛网站| 久热精品在线视频| 中文久久乱码一区二区| 国内精品模特av私拍在线观看| 欧美成人一区在线| 午夜精品福利在线| 亚洲狼人综合| 牛牛影视久久网| 校园激情久久| av成人黄色| 在线精品视频一区二区三四| 欧美视频导航| 免费一级欧美片在线观看| 午夜精品免费在线| 日韩一区二区精品在线观看| 老司机成人网| 久久精品免费播放| 亚洲一二区在线| 日韩视频永久免费| 在线成人国产| 国产日韩欧美亚洲| 最新国产乱人伦偷精品免费网站| 一本色道久久综合精品竹菊| 久久精品国产免费观看| 亚洲影视在线| 亚洲视频电影在线| 亚洲美女视频在线观看| 亚洲国产高清一区二区三区| 国产欧美日韩精品在线|