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

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>
            欧美精品一区二区三区在线播放 | 欧美一区二区三区视频| 亚洲国产精品激情在线观看 | 在线天堂一区av电影| 亚洲欧洲精品一区二区精品久久久| 极品尤物av久久免费看| 精品96久久久久久中文字幕无| 在线日本成人| 欧美视频一区二区三区| 日韩视频国产视频| 欧美日韩午夜精品| 国产精品久久一区二区三区| 国产精品蜜臀在线观看| 国产一级揄自揄精品视频| 激情五月婷婷综合| 亚洲乱码国产乱码精品精| 中日韩美女免费视频网站在线观看| 亚洲一区二区在线看| 久久精品国产欧美激情| 免费欧美日韩| 一区二区三区www| 欧美一区二视频在线免费观看| 久久精品九九| 欧美日产一区二区三区在线观看 | 欧美精品麻豆| 国产精品入口66mio| 精品1区2区| 亚洲午夜精品久久久久久浪潮| 小处雏高清一区二区三区| 欧美国产在线视频| 欧美一区二区三区四区在线观看地址| 玖玖综合伊人| 国产一区二区三区四区三区四| 99热精品在线| 牛人盗摄一区二区三区视频| 亚洲午夜精品网| 欧美黄色一区| 亚洲国产网站| 欧美h视频在线| 欧美一区二区三区久久精品茉莉花| 欧美精品成人在线| 国产欧亚日韩视频| 亚洲自拍啪啪| 99伊人成综合| 欧美色图天堂网| 99视频精品全部免费在线| 欧美成年视频| 久久精品久久99精品久久| 国产精品无码永久免费888| 中文久久精品| 最新国产の精品合集bt伙计| 欧美一级大片在线观看| 欧美日韩在线播放一区二区| 91久久精品一区二区三区| 久久大逼视频| 最新日韩在线| 亚洲欧洲综合另类在线| 欧美88av| 亚洲欧美综合v| 欧美视频一区| 一区二区三区三区在线| 亚洲第一精品久久忘忧草社区| 午夜精品国产| 亚洲国产婷婷综合在线精品| 黑人操亚洲美女惩罚| 伊人夜夜躁av伊人久久| 西西裸体人体做爰大胆久久久| 91久久久久久| 欧美大片一区二区三区| 精品动漫3d一区二区三区免费版| 欧美亚洲三区| 亚洲一区二区免费| 国产精品乱码久久久久久| 国产精品99久久久久久有的能看| 欧美激情一区二区三级高清视频| 久久久亚洲一区| 亚洲综合三区| 欧美午夜电影网| 日韩系列在线| 最新高清无码专区| 欧美福利精品| 亚洲精品在线免费观看视频| 欧美不卡一区| 免费亚洲一区| 性欧美超级视频| 欧美一级在线亚洲天堂| 国产麻豆午夜三级精品| 欧美一区二区在线播放| 亚洲免费在线视频一区 二区| aaa亚洲精品一二三区| 欧美日韩精品| 亚洲欧美电影在线观看| 亚洲自拍啪啪| 一区精品在线| 亚洲国产精品一区二区三区| 99热在这里有精品免费| 国产精品国产三级国产aⅴ无密码| 夜夜精品视频| 亚洲午夜久久久久久久久电影院 | 亚洲国产91| 亚洲日本无吗高清不卡| 欧美视频在线观看一区| 亚洲欧美中文日韩在线| 亚洲欧美一区二区在线观看| 国内精品久久久久久影视8| 免费在线成人av| 欧美日韩和欧美的一区二区| 久久国产一二区| 欧美国产日产韩国视频| 亚洲欧美bt| 久久国产99| 亚洲精选大片| 午夜精品久久久久久久99热浪潮| 伊人成人网在线看| 中文国产成人精品久久一| 国产一区二区三区免费观看| 欧美在线免费观看| 国产精品电影网站| 欧美电影免费观看| 亚洲性图久久| 亚洲日本在线视频观看| 欧美视频一区在线观看| 久久久综合精品| 欧美日韩视频| 久久美女性网| 欧美日韩亚洲一区二| 亚洲二区在线观看| 国产视频一区在线| 亚洲美女视频在线观看| 国产亚洲欧美激情| 在线亚洲一区二区| 亚洲欧洲一级| 久久久久久久高潮| 日韩午夜av| 欧美另类一区二区三区| 欧美成人一区二区三区片免费| 国产精品乱子乱xxxx| 亚洲精品一二| 最近看过的日韩成人| 久久久久久欧美| 欧美在线视频a| 国产精品高潮呻吟久久av无限| 久久精品30| 欧美日韩一区二区高清| 亚洲高清一区二| 在线欧美三区| 老司机一区二区三区| 麻豆国产va免费精品高清在线| 国产亚洲精品福利| 亚洲午夜女主播在线直播| 一本色道久久综合一区| 欧美freesex交免费视频| 免费亚洲视频| 国产精品亚洲综合色区韩国| 老巨人导航500精品| 国产一区二区成人久久免费影院| 日韩天堂在线视频| 亚洲神马久久| 欧美色综合天天久久综合精品| 欧美电影资源| 亚洲欧洲精品一区二区三区波多野1战4 | 在线看片欧美| 欧美一区亚洲| 欧美亚洲日本国产| 国产一区二区视频在线观看 | 麻豆91精品| 亚洲欧洲综合另类在线| 99热在线精品观看| 欧美日韩中文字幕在线视频| 一区二区激情| 亚洲在线观看| 国产亚洲精品aa午夜观看| 久久久精品久久久久| 亚洲电影欧美电影有声小说| **网站欧美大片在线观看| 欧美成人精品高清在线播放| 亚洲免费观看高清完整版在线观看熊 | 欧美精品一区二区三区四区| 99国产一区二区三精品乱码| 中文日韩欧美| 国产日韩欧美在线看| 久久米奇亚洲| 日韩视频专区| 久久国产精品久久久久久久久久| 久久蜜桃资源一区二区老牛| 一本色道久久综合亚洲精品高清| 午夜精品久久久久久久99黑人| 国产日韩欧美综合| 欧美精品福利视频| 久久爱www久久做| 亚洲国产三级网| 午夜精品久久99蜜桃的功能介绍| 国产精品久久久久天堂| 亚洲欧美一区二区视频| 亚洲高清色综合| 亚洲欧美三级伦理| 亚洲精品一区二区三区四区高清 | 亚洲精品偷拍| 国产精品丝袜xxxxxxx| 久久久精品动漫|