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

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
本以為最長上升子序列,沒錯,最長的步數對了,但是因為路徑更新有無,所以還是一直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左右我居然這么多,暈
思路還是最長上升子序列
不過更新路徑的函數代碼如下
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;
}
}
********************************
即如果路徑長度相同的話,就執行cmp從而判斷字典序!更新字典序!很浪費時間!
********************************  回復  更多評論
  
# re: poj 2111 Millenium Leapcow
2008-12-24 12:43 | Knight
魷魚大牛的思路
從n*n開始搜索到1結束DP更新路徑
排名20 3160K 157MS C++ 1228B
還行經典代碼如下:
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;
}
}  回復  更多評論
  

只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


<2009年8月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
303112345

常用鏈接

留言簿(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>
            亚洲高清自拍| 久久国产视频网| 一本在线高清不卡dvd| 欧美性一二三区| 欧美高清视频一区二区| 美女精品一区| 欧美激情精品久久久久久变态| 欧美一区二区三区四区夜夜大片 | 理论片一区二区在线| 亚洲欧美日韩精品久久奇米色影视| 亚洲国产精品久久久久婷婷884| 久久不见久久见免费视频1| 亚洲午夜久久久| 99精品视频免费| 一本一本久久| 久久精品国产一区二区电影| 中文精品视频| 久久精品国产精品| 最近中文字幕日韩精品| 日韩一区二区精品葵司在线| 欧美 日韩 国产在线| 免费视频一区| 在线观看日韩www视频免费 | 久久综合导航| 亚洲一区二区三区高清不卡| 久久综合伊人77777麻豆| 99精品免费视频| 亚洲欧洲精品一区| 亚洲国产精品成人综合色在线婷婷| 久久精品在线观看| 久久尤物视频| 亚洲黄色三级| 先锋影音国产精品| 亚洲视频中文字幕| 亚洲毛片av在线| 亚洲精品美女免费| 亚洲高清久久网| 亚洲国产精品一区在线观看不卡 | 亚洲美女精品成人在线视频| 1024亚洲| 亚洲综合精品| 久久免费视频网| 亚洲精品社区| 亚洲视频在线观看网站| 亚洲午夜小视频| 欧美在线视频免费| 免费的成人av| 国产精品hd| 国产一区二三区| 亚洲精品一区二区三区99| 在线综合亚洲| 欧美成人精品1314www| 亚洲韩国精品一区| 亚洲天堂网在线观看| 久久嫩草精品久久久久| 欧美高清视频一区二区| 一区二区三区四区在线| 新67194成人永久网站| 免费成人av在线| 国产日韩1区| 亚洲精品久久视频| 久久亚洲精品中文字幕冲田杏梨 | 欧美一区二区三区精品| 亚洲第一区在线| 亚洲黄色有码视频| 国产精品久久久久久影视| 久久久久欧美精品| 欧美成人午夜激情视频| 亚洲一区二区av电影| 亚洲欧美另类在线| 日韩西西人体444www| 久久综合99re88久久爱| 久久久一二三| 国产精品久久久久9999| 欧美99久久| 国内精品久久久| 一区二区三区色| 亚洲私人影院| 欧美日韩一级视频| 一区二区三区精品在线| 亚洲欧美在线磁力| 欧美另类专区| 欧美一区二区三区在线免费观看| 99视频精品| 在线成人av.com| 日韩图片一区| 今天的高清视频免费播放成人 | 欧美高清不卡| 欧美成人嫩草网站| 久久久久成人精品免费播放动漫| 亚洲图片自拍偷拍| 99国产麻豆精品| 欧美一区2区视频在线观看| 亚洲精品在线免费观看视频| 中日韩高清电影网| 亚洲欧洲精品成人久久奇米网| 亚洲免费观看在线观看| 在线播放日韩欧美| 亚洲人成亚洲人成在线观看图片| 国产精品你懂得| 亚洲精品久久久久久久久久久| 国产精品三级久久久久久电影| 日韩一区二区精品葵司在线| 日韩亚洲欧美一区| 另类尿喷潮videofree| 久久九九电影| 国产日韩欧美高清免费| 亚洲神马久久| 午夜精品久久久久久久久| 欧美日韩国产综合网| 亚洲国产精品一区| 夜夜嗨av一区二区三区免费区| 欧美极品一区| 亚洲一区在线看| 能在线观看的日韩av| 99综合在线| 国内成人精品视频| 欧美日韩一二三四五区| 香蕉久久夜色精品| 亚洲精品视频免费在线观看| 午夜精品区一区二区三| 国语自产精品视频在线看| 老巨人导航500精品| 亚洲美女av黄| 欧美大片在线看| 亚洲欧美亚洲| 久久国产加勒比精品无码| 久久亚洲高清| 亚洲国产欧美另类丝袜| 久久国产日韩欧美| 国产一区二区电影在线观看| 欧美久久电影| 亚洲欧美日韩视频一区| 99国产成+人+综合+亚洲欧美| 欧美一级专区免费大片| 亚洲每日在线| 国产日韩av在线播放| 国产伦精品一区二区| 欧美高清视频一区二区| 美女91精品| 亚洲欧美日韩精品久久| 午夜视频一区在线观看| 亚洲欧美视频| 夜夜嗨av一区二区三区中文字幕 | 亚洲黄一区二区| 开元免费观看欧美电视剧网站| 亚洲一区二区精品在线观看| 午夜精品一区二区在线观看 | 99re亚洲国产精品| 中国亚洲黄色| 欧美在线视频观看| 免费在线欧美黄色| 亚洲国产二区| 午夜激情一区| 免费精品99久久国产综合精品| 久久久www免费人成黑人精品| 美女主播一区| 欧美色偷偷大香| 欧美福利小视频| 日韩视频免费大全中文字幕| 中日韩午夜理伦电影免费| 久久精彩视频| 国产精品va在线播放| 国产精品一区二区在线| 亚洲精品视频在线观看网站| 在线亚洲一区观看| 久久久综合网| 亚洲一区二区伦理| 亚洲欧美偷拍卡通变态| 欧美日韩亚洲高清一区二区| 精品99视频| 久久精品视频播放| 亚洲综合成人在线| 欧美视频网站| 亚洲视频图片小说| 亚洲精品一区二区在线| 久久九九全国免费精品观看| 国产美女精品人人做人人爽| 中文高清一区| 日韩午夜精品| 欧美日韩精品伦理作品在线免费观看| 在线成人激情视频| 亚洲国产精品va在看黑人| 久久久福利视频| 亚洲欧洲久久| 亚洲精品四区| 国产亚洲精久久久久久| 裸体丰满少妇做受久久99精品| 毛片av中文字幕一区二区| 亚洲电影成人| 99在线|亚洲一区二区| 欧美日韩综合视频| 欧美亚洲在线播放| 久久精品卡一| 香蕉尹人综合在线观看| 久久久久久999| 一区二区三区视频在线| 欧美在线视频网站| 一区二区三区久久精品| 亚洲欧美伊人|