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

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>
            欧美不卡在线视频| 久久―日本道色综合久久| 欧美午夜电影网| 欧美日韩国产精品| 欧美日韩免费观看一区=区三区| 欧美成熟视频| 欧美日本二区| 国产精品久久网站| 国产一区自拍视频| 亚洲国产小视频| 亚洲深夜福利在线| 欧美在线观看一区二区| 久久亚洲影院| 99成人在线| 欧美在线看片| 欧美日本在线观看| 国产在线观看一区| 一个色综合导航| 久久精品免费电影| 亚洲六月丁香色婷婷综合久久| 亚洲一区国产视频| 欧美sm视频| 国产一区成人| 亚洲视频一区在线观看| 久久久久国产精品人| 亚洲精品小视频| 久久嫩草精品久久久精品| 欧美调教vk| 亚洲欧洲另类| 久久久久看片| 宅男精品视频| 蜜桃久久av| 久久久国产精品一区二区中文 | 日韩亚洲综合在线| 性刺激综合网| 欧美三日本三级三级在线播放| 精品999成人| 亚洲欧美自拍偷拍| 亚洲精品视频在线| 玖玖玖国产精品| 国产日韩欧美日韩| 亚洲欧美成人网| 亚洲精品永久免费精品| 久久久国产精品一区二区中文| 国产精品成人观看视频免费 | 国产精品久久久久久久久久免费| 亚洲激情视频在线播放| 亚洲欧美国产另类| 亚洲精品日韩欧美| 欧美国产日本高清在线| 曰韩精品一区二区| 久久在线免费观看视频| 性欧美8khd高清极品| 国产免费一区二区三区香蕉精| 亚洲午夜精品| 国产精品99久久久久久久vr| 欧美精品亚洲一区二区在线播放| 伊人久久婷婷| 欧美国产日韩精品| 老司机一区二区三区| 亚洲电影在线免费观看| 欧美成人国产| 欧美成人免费大片| 亚洲另类自拍| 99re6热在线精品视频播放速度 | 欧美一区二区在线视频| 国产精自产拍久久久久久蜜| 欧美中文字幕在线| 久久狠狠久久综合桃花| 精品91久久久久| 欧美91视频| 欧美乱大交xxxxx| 亚洲视频在线观看免费| 亚洲一区二区在线免费观看视频| 国产精品综合久久久| 久久夜色精品国产亚洲aⅴ| 久久综合九色九九| 99精品国产一区二区青青牛奶| 亚洲美女诱惑| 国产亚洲a∨片在线观看| 免费成人av在线| 欧美日韩精品一本二本三本| 亚洲欧美日韩专区| 欧美在线欧美在线| 亚洲精品日产精品乱码不卡| 一本久久精品一区二区| 国产一区二区三区精品欧美日韩一区二区三区 | 尤物在线观看一区| 亚洲国产一区二区三区青草影视| 美女尤物久久精品| 99精品福利视频| 亚洲男人的天堂在线观看| 国语自产精品视频在线看| 亚洲成人在线网站| 国产欧美精品在线播放| 欧美电影资源| 国产精品女主播| 欧美高清在线视频| 国产精品一区二区久久国产| 欧美高清在线视频观看不卡| 国产精品成人观看视频免费| 欧美成人激情在线| 国产精品美女午夜av| 亚洲国产精品va| 狠狠爱www人成狠狠爱综合网| 最新成人在线| 伊人婷婷久久| 亚洲欧美日本伦理| 一区二区激情小说| 美女国产一区| 久久免费黄色| 国产日韩视频| 亚洲免费小视频| 亚洲无线视频| 欧美激情综合五月色丁香小说| 久久午夜影视| 国产综合色产| 欧美伊人久久| 欧美一级播放| 国产精品电影网站| 日韩一区二区福利| 99综合精品| 欧美国产成人在线| 欧美aa国产视频| 精品av久久久久电影| 午夜精品久久久久| 欧美一区二区三区在线观看视频| 欧美日韩国产123| 日韩亚洲欧美精品| 亚洲天堂免费在线观看视频| 欧美精品日本| 亚洲日韩第九十九页| 亚洲国产精品一区制服丝袜| 久久激情网站| 免费中文日韩| 91久久线看在观草草青青| 免费观看久久久4p| 亚洲国产高清高潮精品美女| 亚洲激情电影在线| 欧美精品免费播放| 一区二区精品在线观看| 亚洲午夜精品网| 国产精品久久久久一区二区三区共 | 99这里只有精品| 在线观看欧美一区| 久久国产免费| 可以免费看不卡的av网站| 红杏aⅴ成人免费视频| 久久久久国产精品www| 欧美α欧美αv大片| 亚洲精品一二三区| 欧美日韩裸体免费视频| 亚洲一区二区成人在线观看| 久久er99精品| 亚洲第一页中文字幕| 欧美激情亚洲另类| 这里只有视频精品| 久久精品视频免费观看| 亚洲激情六月丁香| 欧美午夜一区二区福利视频| 欧美一区免费| 亚洲国产欧美在线人成| 亚洲欧美日韩视频一区| 韩国精品久久久999| 欧美福利小视频| 亚洲一区日韩在线| 久久男人资源视频| 一区二区av| 国产一区二区无遮挡| 欧美承认网站| 欧美伊人久久大香线蕉综合69| 亚洲国产91精品在线观看| 午夜欧美不卡精品aaaaa| 在线欧美日韩| 国产精品美女在线观看| 久久亚洲美女| 亚洲欧美国产一区二区三区| 欧美黄色网络| 久久精品综合| 亚洲天天影视| 亚洲精品美女在线观看| 国产精品一区二区久久久久| 免费中文字幕日韩欧美| 亚洲欧美伊人| 99视频+国产日韩欧美| 美女被久久久| 欧美中文字幕在线视频| 亚洲少妇自拍| 亚洲国产视频a| 黄色欧美成人| 国产女优一区| 欧美色图五月天| 欧美大成色www永久网站婷| 亚洲男人第一av网站| 99日韩精品| 亚洲全部视频| 亚洲国产成人久久| 欧美成人一区二免费视频软件| 亚洲影视综合| 亚洲一区在线视频|