日韩性视频-久久久蜜桃-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)的全部內容,希望文章能夠幫你解決所遇到的問題。

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

主站蜘蛛池模板: 91国语对白 | 最新不卡av | 免费毛片网站 | 免费国产羞羞网站视频 | 在线视频成人 | www.九色.com| 少妇2做爰交换朴银狐 | 97视频一区 | 亚洲日本欧美精品 | 河北彩花中文字幕 | 欧美国产一二三区 | 亚洲中午字幕 | 日本一级黄色大片 | 日本美女性生活视频 | 性自由色xxxx免费视频 | 性视频网址 | 日韩欧美一二三 | 91成人天堂久久成人 | 天天干夜夜夜夜 | 欧美日韩免费一区二区 | 久久66热这里只有精品 | 不卡av在线免费观看 | 久久成人精品视频 | 日韩在线观看视频一区 | 欧美成人综合视频 | www.亚洲| 黄色片中文字幕 | 自宅警备员在线观看 | 日韩久久中文字幕 | 青青国产精品视频 | 欧美粗又大 | 波多野在线 | 怡红院男人的天堂 | 古装做爰无遮挡三级视频 | 波多野结衣 一区 | 亚洲第一区视频 | 羞辱极度绿帽vk | 欧美精品一级二级 | 香蕉视频免费 | 国产精品乱码一区二三区小蝌蚪 | 午夜亚洲精品 | 亚洲国产丝袜 | 欧美成人精品一区二区男人看 | 久久精品三级 | 亚洲情涩| www.亚洲成人| 最新一区二区三区 | 性生活毛片 | 波多野结衣电车 | 中文字幕亚洲无线码在线一区 | 91激情网 | 懂色av一区二区三区免费 | 极品尤物一区二区 | 欧美性受xxxxx | 日韩高清黄色 | 男人疯狂高潮呻吟视频 | 欧美婷婷六月丁香综合色 | 长腿校花无力呻吟娇喘的视频 | 中文字幕在线观看一区二区三区 | 国产不卡精品视频 | 久久久久久夜 | 青草91 | 特黄级 | 国产精品桃色 | 我要看黄色大片 | 中文字幕2021| 国产精品呦呦 | 成人视屏在线观看 | 69av在线视频 | 免费观看国产精品视频 | 欧美午夜在线视频 | 一级黄色片在线播放 | 黄色肉肉视频 | 99热亚洲精品 | 国产欧美不卡 | 国产色啪| 亚洲欧洲成人 | 特一级黄色 | 欧美成人久久久免费播放 | 亚洲日本精品一区 | 日韩视频免费看 | 国产午夜精品一区二区三区欧美 | 欧美无砖专区免费 | 无码久久av一区二区三区 | av中文在线播放 | 一区二区视频在线播放 | 手机在线精品视频 | 精品影视| 日韩在线观看精品 | 成人小视频在线看 | 亚洲综合五区 | 小嫩嫩12欧美 | 精品啪啪 | 在线中文字幕av | 一二三区免费视频 | 亚洲第一男人天堂 | 午夜写真片福利电影网 | 日韩中文字幕网站 | 贝利弗山的秘密1985版免费观看 |