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

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年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>
            国产精品香蕉在线观看| 久久国内精品自在自线400部| 亚洲欧美日韩精品一区二区| 亚洲三级毛片| 日韩亚洲欧美成人| 在线综合亚洲| 午夜精品福利一区二区三区av| 欧美一区二区三区成人| 久久久精品一区| 亚洲福利视频在线| 日韩视频专区| 久久成人18免费网站| 久久综合久久久| 欧美性片在线观看| 激情久久影院| 亚洲校园激情| 欧美国产国产综合| 亚洲一区成人| 牛人盗摄一区二区三区视频| 国产精品久久综合| 亚洲三级视频在线观看| 亚洲午夜在线视频| 牛人盗摄一区二区三区视频| 亚洲视频在线观看三级| 鲁鲁狠狠狠7777一区二区| 国产精品伦子伦免费视频| 亚洲黄色在线| 久久天天综合| 日韩视频精品在线观看| 欧美在线999| 亚洲欧洲在线一区| 久久精品天堂| 国产精品乱看| 宅男噜噜噜66一区二区| 欧美电影在线观看完整版| 亚洲综合色自拍一区| 欧美美女bbbb| 亚洲人成人一区二区三区| 久久aⅴ乱码一区二区三区| 最新成人av网站| 久久琪琪电影院| 国产偷久久久精品专区| 亚洲欧美日韩高清| 日韩一级免费观看| 欧美日韩国产美女| 亚洲美女啪啪| 亚洲欧洲在线观看| 欧美精品九九99久久| 亚洲精品国久久99热| 久久亚洲一区| 久久精品国产2020观看福利| 国产精品午夜春色av| 亚洲欧美影院| 亚洲深夜福利在线| 国产精品久久波多野结衣| 亚洲四色影视在线观看| 日韩午夜三级在线| 欧美私人网站| 亚洲欧美激情视频| 亚洲男人第一网站| 国产精品资源在线观看| 先锋亚洲精品| 欧美一区免费| 在线观看视频一区二区| 欧美v国产在线一区二区三区| 久久久久综合网| 亚洲电影成人| 亚洲人成绝费网站色www| 欧美精品电影| 亚洲一区亚洲二区| 亚洲一区三区视频在线观看| 国产麻豆综合| 看片网站欧美日韩| 欧美91大片| 亚洲一区不卡| 性欧美暴力猛交69hd| 伊伊综合在线| 亚洲免费电影在线观看| 国产精品色午夜在线观看| 久久精品日产第一区二区| 久久婷婷亚洲| 亚洲天堂免费观看| 欧美一区二区三区四区在线观看地址 | 久久久久久久综合日本| 在线不卡视频| 亚洲精品久久7777| 国产久一道中文一区| 久久欧美肥婆一二区| 米奇777超碰欧美日韩亚洲| 中日韩午夜理伦电影免费| 久久国产免费| 在线视频一区二区| 久久国产一区二区| 中国av一区| 久久九九精品| 午夜精品免费在线| 男女激情久久| 久久久久久久综合日本| 女主播福利一区| 久久国产婷婷国产香蕉| 欧美成va人片在线观看| 欧美中日韩免费视频| 欧美片第一页| 欧美激情按摩在线| 国产主播一区二区| 亚洲天堂成人在线观看| 亚洲另类自拍| 久久久亚洲精品一区二区三区| 亚洲永久视频| 欧美片网站免费| 亚洲国产成人久久综合一区| 国产主播一区二区三区| 亚洲性感美女99在线| a4yy欧美一区二区三区| 久久夜色精品国产噜噜av| 欧美在线免费一级片| 欧美午夜片在线观看| 亚洲日本成人| 亚洲美女黄网| 欧美精品一区二区三区一线天视频 | 国产精品久久久久秋霞鲁丝| 亚洲激情网站| 亚洲黄色免费| 久久手机免费观看| 久久香蕉国产线看观看av| 国产精品亚洲美女av网站| 日韩视频一区二区在线观看| 亚洲裸体在线观看| 欧美激情欧美激情在线五月| 欧美国产成人精品| 亚洲国产成人高清精品| 久久综合久久久| 欧美成年人在线观看| 亚洲福利专区| 欧美91精品| 亚洲美女av黄| 亚洲一区二区三区在线视频| 欧美日韩性生活视频| 亚洲最新合集| 欧美一区国产一区| 国产一区二区精品久久91| 欧美一级欧美一级在线播放| 久久久久一区二区三区四区| 激情综合视频| 欧美大片免费久久精品三p | 欧美一区免费| 亚洲欧美一区二区三区久久| 亚洲欧美成人在线| 国产精品乱码一区二区三区| 亚洲一区二区高清视频| 久久精品综合| 亚洲国产精品一区二区久| 免费美女久久99| 日韩写真在线| 久久aⅴ乱码一区二区三区| 狠狠色2019综合网| 欧美激情第8页| 亚洲已满18点击进入久久| 久久亚洲电影| 一本色道久久综合狠狠躁篇怎么玩 | 欧美国产丝袜视频| av成人免费在线| 久久一区二区三区国产精品| 亚洲精品一区二区三区樱花 | 国产精品自在欧美一区| 久久不射中文字幕| 亚洲精品视频免费观看| 午夜精品久久久久久久白皮肤| 影音先锋久久精品| 欧美日韩一区在线| 久久久视频精品| 一道本一区二区| 欧美xx视频| 欧美一区二视频| 99伊人成综合| 精品91久久久久| 国产精品亚发布| 欧美成人中文字幕在线| 午夜精品免费视频| 99re6这里只有精品| 牛牛精品成人免费视频| 性高湖久久久久久久久| 日韩一级片网址| 在线成人av| 国产美女精品视频| 欧美日韩国产探花| 卡通动漫国产精品| 欧美在线啊v| 亚洲图片在区色| 亚洲精品欧美在线| 欧美成人免费网站| 久久人91精品久久久久久不卡| 亚洲欧美日韩一区二区| 日韩亚洲在线| 亚洲日本国产| 亚洲国产精品www| 伊人天天综合| 国内精品久久久久久| 国产一区欧美| 狠狠色狠狠色综合日日91app|