日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Wang Xifeng's Little Plot (poj 5024 DFS)

發布時間:2023/12/20 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Wang Xifeng's Little Plot (poj 5024 DFS) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Wang Xifeng's Little Plot

Time Limit: 2000/1000 MS (Java/Others)????Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 133????Accepted Submission(s): 89


Problem Description 《Dream of the Red Chamber》(also 《The Story of the Stone》) is one of the Four Great Classical Novels of Chinese literature, and it is commonly regarded as the best one. This novel was created in Qing Dynasty, by Cao Xueqin. But the last 40 chapters of the original version is missing, and that part of current version was written by Gao E. There is a heart breaking story saying that after Cao Xueqin died, Cao's wife burned the last 40 chapter manuscript for heating because she was desperately poor. This story was proved a rumor a couple of days ago because someone found several pages of the original last 40 chapters written by Cao.

In the novel, Wang Xifeng was in charge of Da Guan Yuan, where people of Jia family lived. It was mentioned in the newly recovered pages that Wang Xifeng used to arrange rooms for Jia Baoyu, Lin Daiyu, Xue Baochai and other teenagers. Because Jia Baoyu was the most important inheritor of Jia family, and Xue Baochai was beautiful and very capable , Wang Xifeng didn't want Jia Baoyu to marry Xue Baochai, in case that Xue Baochai might take her place. So, Wang Xifeng wanted Baoyu's room and Baochai's room to be located at two ends of a road, and this road should be as long as possible. But Baoyu was very bad at directions, and he demanded that there could be at most one turn along the road from his room to Baochai's room, and if there was a turn, that turn must be ninety degree. There is a map of Da Guan Yuan in the novel, and redists (In China English, one whose job is studying 《Dream of the Red Chamber》is call a "redist") are always arguing about the location of Baoyu's room and Baochai's room. Now you can solve this big problem and then become a great redist.
Input The map of Da Guan Yuan is represented by a matrix of characters '.' and '#'. A '.' stands for a part of road, and a '#' stands for other things which one cannot step onto. When standing on a '.', one can go to adjacent '.'s through 8 directions: north, north-west, west, south-west, south, south-east,east and north-east.

There are several test cases.

For each case, the first line is an integer N(0<N<=100) ,meaning the map is a N × N matrix.

Then the N × N matrix follows.

The input ends with N = 0.
Output For each test case, print the maximum length of the road which Wang Xifeng could find to locate Baoyu and Baochai's rooms. A road's length is the number of '.'s it includes. It's guaranteed that for any test case, the maximum length is at least 2.
Sample Input 3 #.# ##. ..# 3 ... ##. ..# 3 ... ### ..# 3 ... ##. ... 0
Sample Output 3 4 3 5
Source 2014 ACM/ICPC Asia Regional Guangzhou Online
Recommend hujie???|???We have carefully selected several similar problems for you:??5031?5030?5029?5028?5027? 題意:求兩點使它們的距離最大,只能轉一次彎,并且是90度。 思路:遍歷全圖,找最大值,注意dir數組按照一個圓寫,這樣好控制方向,搜的時候有三個方向:直走,左轉90度,右轉90度。另外注意從邊界進入開始搜。 代碼: #include <iostream> #include <cstdio> using namespace std;int dir[8][2]={-1,-1,-1,0,-1,1,0,1,1,1,1,0,1,-1,0,-1}; char mp[110][110]; int N,maxx;bool ISok(int x,int y) {if (x>=0&&x<N&&y>=0&&y<N&&mp[x][y]!='#')return true;return false; }void dfs(int Dir,int x,int y,int step,int number) {int flag=0,dx,dy;dx=x+dir[Dir][0]; //直走dy=y+dir[Dir][1];if (ISok(dx,dy)){flag=1;dfs(Dir,dx,dy,step+1,number);}if (number){int D=(Dir+2)%8; //左轉dx=x+dir[D][0];dy=y+dir[D][1];if (ISok(dx,dy)){flag=1,number=0;dfs(D,dx,dy,step+1,number);}D=(Dir+6)%8; //右轉dx=x+dir[D][0];dy=y+dir[D][1];if (ISok(dx,dy)){flag=1,number=0;dfs(D,dx,dy,step+1,number);}}if (flag&&step>maxx)maxx=step; }int main() {int i,j;while (scanf("%d",&N),N){for (i=0;i<N;i++)scanf("%s",mp[i]);maxx=0;for (i=0;i<N;i++){for (j=0;j<N;j++){if (i==0||j==0||i==(N-1)||j==(N-1)) //從邊界進入{if (mp[i][j]!='#'){for (int t=0;t<8;t++)dfs(t,i,j,1,1);}}}}printf("%d\n",maxx+1);}return 0; }

轉載于:https://www.cnblogs.com/i8888/p/4044016.html

總結

以上是生活随笔為你收集整理的Wang Xifeng's Little Plot (poj 5024 DFS)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 久久国产视频播放 | 国产77777 | 久久久久无码国产精品不卡 | 国产内射老熟女aaaa∵ | 国产91小视频 | 日韩精品在线免费观看视频 | 国产一区二区三区影视 | 夜夜夜撸 | 亚洲精品xxxx | 狠狠操在线播放 | 久久e热 | 神马午夜在线观看 | 精品国产一区二区三区久久久久久 | 中文字幕乱码一区二区三区 | 久久精品一区二区三区不卡牛牛 | 瑟瑟在线观看 | 免费a级黄色片 | 久久久在线视频 | 777久久久精品一区二区三区 | 国产精品福利片 | 97视频在线免费 | 亚洲永久在线 | 波多野结衣视频播放 | 欧美韩日一区二区 | 尤物193.com| 99天堂网 | 丁香社区五月天 | 午夜伦理在线观看 | 一本久道综合色婷婷五月 | 中国少妇毛片 | 国产精品成人电影在线观看 | 日韩精品在线免费视频 | 日日夜精品| 荡女精品导航 | 久久综合成人网 | 国产经典三级在线 | 夜夜草av| 久久艹艹| 用力插视频 | 欧美国产日韩视频 | 黄色片免费 | 女人张开腿让男人桶爽 | 污污网站免费在线观看 | 摸摸大奶子 | 在线观看国产一区二区 | 影音先锋中文字幕在线视频 | 凹凸日日摸日日碰夜夜 | 欧美久久精品 | va在线播放| 国产亚洲高清视频 | 黄色香蕉网站 | 国产又粗又猛又大爽 | v片在线看 | 欧洲女性下面有没有毛发 | 亚洲成人网av | 欧美性高潮视频 | 天天躁日日躁狠狠躁免费麻豆 | 麻豆私人影院 | 日本亚洲色大成网站www久久 | 日韩涩| 六月久久| 女性爱爱视频 | 日韩精品一区二区三区四区五区 | 亚洲天堂视频网站 | 三级精品视频 | 97香蕉碰碰人妻国产欧美 | 老司机精品福利导航 | 你懂的在线观看网站 | 美女在线观看视频 | 久久亚洲国产成人精品性色 | 四虎影视精品 | 天天视频亚洲 | 日本不卡一区 | 久操操 | 男女网站免费 | 日韩欧美区 | 新婚夫妇白天啪啪自拍 | 中文字幕22页 | 国产成人麻豆精品午夜在线 | 富二代成人短视频 | 91午夜在线观看 | av网站在线免费播放 | 国产一区二区啪啪啪 | 超碰在线网址 | 人妻奶水人妻系列 | av老司机在线观看 | 日韩欧美三级在线 | 无码人妻精品一区二 | 成人免费一级 | 国产欧美久久久精品免费 | 丰满熟妇被猛烈进入高清片 | 亚洲理论在线观看 | 欧美一级黄色片视频 | 国产成人视屏 | 欧美大白屁股 | 黄色国产一级片 | 国产精品情侣 | 亚洲午夜伦理 | 精品人妻少妇一区二区三区 |