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

posts - 74,  comments - 33,  trackbacks - 0

Problem Statement

???? According to research conducted recently, listening to classical music increases one's mental abilities, while listening to metal decreases them. Now, yet another experiment is being conducted to try to prove or disprove this statement.

In this new experiment, a mouse is placed in a rectangular maze consisting of NxM squares. Each square either contains a wall or is empty. The maze is structured in such a way that for any two empty squares, there exists exactly one path between them. A path is a sequence of pairwise distinct empty squares such that every two consecutive squares are neighboring. Two squares are considered neighboring if they share a common edge.

One of the empty squares in the maze contains a piece of cheese. The mouse's goal is to reach that square without visiting the same square twice. The mouse can only move between neighboring squares. Since the mouse has been listening to classical music for a week, he is extremely intelligent and guaranteed to achieve his goal.

As the mouse moves from his starting point to the cheese, he may encounter some squares where he must choose between several neighboring squares to continue. This happens when the mouse steps into a square which has more than one neighboring empty square, excluding the square from which he came, or when he has more than one neighboring empty square at the start. These situations are called "decisions" and the mouse will always make the right choice.

You are given a vector <string> maze representing the maze. It contains N elements, each containing M characters. Empty squares are denoted by '.', walls are denoted by uppercase 'X', the mouse's starting point is denoted by 'M', and the square containing the cheese is denoted by '*'. Return the number of decisions the mouse will make on his way to the cheese.

Definition

????
Class: MazeWanderingEasy
Method: decisions
Parameters: vector <string>
Returns: int
Method signature: int decisions(vector <string> maze)
(be sure your method is public)
????

Constraints

- maze will contain between 1 and 50 elements, inclusive.
- Each element of maze will contain between 1 and 50 characters, inclusive.
- Elements of maze will be of the same length.
- maze will contain only '.', 'X', 'M' or '*' characters.
- There will be exactly one '*' character in maze.
- There will be exactly one 'M' character in maze.
- For every pair of empty squares in the maze, there will exist exactly one path between them.

Examples

0)
????
{"*.M"}
Returns: 0
From each square, the mouse can only move to one other square, so he never has to make any decisions.
1)
????
{"*.M",
 ".X."}
Returns: 1
The mouse has to make a decision right at the start.
2)
????
{"...",
 "XMX",
 "..*"}
Returns: 2
The mouse makes decisions at both squares before reaching the cheese.
3)
????
{".X.X......X",
 ".X*.X.XXX.X",
 ".XX.X.XM...",
 "......XXXX."}
Returns: 3
4)
????
{"..........*",
 ".XXXXXXXXXX",
 "...........",
 "XXXXXXXXXX.",
 "M.........."}
Returns: 0

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.
這道題是簡(jiǎn)單的BFS由于 對(duì)C++的不熟悉導(dǎo)致比賽的時(shí)候 怎么寫(xiě)一直猶豫不決剛才搞了搞C++終于寫(xiě)出來(lái)了 原來(lái)可以這樣寫(xiě)的

#include < cstdio >
#include
< vector >
#include
< queue >
#include
< string >
#include
< cstring >
#define ?MAXN?120
using ? namespace ?std;
const ? int ?dir[ 4 ][ 2 ] = { { - 1 , 0 } , { 1 , 0 } , { 0 , - 1 } , { 0 , 1 } } ;
struct ?NODE {
????
int ?x,y,sum;????
}
pt;
queue
< NODE > Q;
class ?MazeWanderingEasy {
????
public ?:
????????
int ?decisions(vector < string > ?maze) {
????????????
int ?n,m,i,j,all,res;
????????????n
= maze.size();m = maze[ 0 ].length();
????????????
while ( ! Q.empty())Q.pop();
????????????
bool ?mark[MAXN][MAXN];
????????????memset(mark,
0 , sizeof (mark));
????????????
for (i = 0 ;i < n;i ++ )
????????????????
for (j = 0 ;j < m;j ++ )
????????????????????
if (maze[i][j] == ' M ' ) {
????????????????????????pt.x
= i,pt.y = j,pt.sum = 0 ;
????????????????????????Q.push(pt);
????????????????????????
break ;
????????????????????}

????????????mark[i][j]
= true ;
????????????
while ( ! Q.empty()) {
????????????????pt
= Q.front();
????????????????
int ?x = pt.x,y = pt.y;
????????????????
if (maze[x][y] == ' * ' ) {
????????????????????res
= pt.sum;
????????????????????
break ;
????????????????}

????????????????
for (all = i = 0 ;i < 4 ;i ++ ) {
????????????????????
int ?nx = x + dir[i][ 0 ];
????????????????????
int ?ny = y + dir[i][ 1 ];
????????????????????
if (nx < n && nx >= 0 && ny < m && ny >= 0 &&! mark[nx][ny] && maze[nx][ny] == ' . ' )all ++ ;????
????????????????}

????????????????
for (all = i = 0 ;i < 4 ;i ++ ) {
????????????????????
int ?nx = x + dir[i][ 0 ];
????????????????????
int ?ny = y + dir[i][ 1 ];
????????????????????
if (nx < n && nx >= 0 && ny < m && ny >= 0 &&! mark[nx][ny] && maze[nx][ny] == ' . ' ) {
????????????????????????mark[nx][ny]
= true ;
????????????????????????pt.x
= nx,pt.y = ny,pt.sum = Q.front().sum + all - 1 ;
????????????????????}
????
????????????????}

????????????????Q.pop();
????????????}

????????????
return ?res;
????????}
????
}
;


?

posted on 2009-05-12 22:10 KNIGHT 閱讀(197) 評(píng)論(0)  編輯 收藏 引用

只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


<2009年5月>
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

常用鏈接

留言簿(8)

隨筆檔案

文章檔案

Friends

OJ

搜索

  •  

最新評(píng)論

閱讀排行榜

評(píng)論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲视频视频在线| 日韩视频在线观看国产| 久久国产视频网站| 亚洲欧美日韩国产成人| 欧美在线地址| 久久精品女人| 欧美激情在线观看| 国产精品久久久| 久久综合图片| 国产精品多人| 99精品热6080yy久久| 久久综合九色综合欧美狠狠| 欧美日韩一区不卡| 久久夜色精品国产噜噜av| 国产精品久久久久久久一区探花 | 亚洲人成人99网站| 亚洲毛片在线| 亚洲第一视频网站| 久久久久久久久久看片| 一区二区三区 在线观看视频| 欧美成人午夜激情| 欧美国产综合视频| 亚洲综合成人在线| 欧美日韩1区2区3区| av成人免费在线| 欧美一区二区三区四区高清 | 欧美日韩一卡| 日韩一区二区精品| 一本久久综合| 国产欧美日韩视频在线观看| 欧美网站大全在线观看| 亚洲综合日韩在线| 国产精品成人久久久久| 亚洲图片在线| 亚洲一区二区三区四区中文| 欧美日韩另类字幕中文| 亚洲免费观看高清完整版在线观看熊| 久久免费黄色| 美日韩精品视频| 99亚洲视频| 在线中文字幕一区| 国产亚洲精品bv在线观看| 蜜臀99久久精品久久久久久软件 | 亚洲女女做受ⅹxx高潮| 一本色道久久综合亚洲精品高清| 国产精品一区在线观看你懂的| 亚洲视频一区二区| 午夜精品久久久久久久久久久久| 国产视频一区二区在线观看| 欧美影院视频| 欧美激情国产日韩| 亚洲一区激情| 美女国产一区| 亚洲免费视频中文字幕| 久久久久久一区| 99精品国产高清一区二区| 红桃视频国产精品| 亚洲美女在线国产| 精品999在线观看| 亚洲一区二区三区777| 国内成人精品视频| 亚洲特级片在线| 在线亚洲高清视频| 欧美成人国产一区二区| 欧美成人午夜影院| 99re热这里只有精品免费视频| 噜噜噜在线观看免费视频日韩| 久久久久久久久久久成人| 国产主播精品在线| 蜜臀av在线播放一区二区三区| 亚洲综合丁香| 欧美日韩精品免费在线观看视频| 久久久精彩视频| 国产一区二区精品| 久久天天综合| 亚洲国产欧美日韩| 亚洲精品一区二区三区av| 欧美精品免费在线观看| 91久久精品一区二区三区| 亚洲区中文字幕| 欧美视频一区二区三区四区| 国产亚洲欧美日韩精品| 久久全球大尺度高清视频| 欧美韩日一区二区| 一本到12不卡视频在线dvd| 欧美日韩一区免费| 欧美一区二区大片| 亚洲国产另类久久精品| 亚洲一级免费视频| 国产精品日本| 欧美成人自拍| 久久久精品2019中文字幕神马| 亚洲国产精品久久久久婷婷884| 欧美成人第一页| 国产精品永久| 欧美日韩一区二区在线观看视频| 亚洲欧美制服另类日韩| 最新日韩精品| 美女黄网久久| 欧美亚洲免费高清在线观看| 亚洲人午夜精品免费| 韩国v欧美v日本v亚洲v| 国产精品一级二级三级| 欧美久久久久久久久久| 久久永久免费| 久久国产免费| 久久精品国产一区二区三区| 亚洲在线观看免费视频| 亚洲无线一线二线三线区别av| 亚洲国产成人精品久久| 亚洲国产日韩一区| 亚洲欧洲日夜超级视频| 欧美成人免费全部| 欧美成人免费全部| 亚洲丶国产丶欧美一区二区三区| 久久久亚洲精品一区二区三区| 欧美一区二区三区免费在线看| 午夜精品一区二区在线观看 | 久久精品国产第一区二区三区| 亚洲小视频在线观看| 午夜精品久久久久久久99水蜜桃 | 激情欧美日韩| 亚洲国产精品一区制服丝袜| 亚洲激情黄色| 中文成人激情娱乐网| 久久成人久久爱| 欧美精品激情在线观看| 国产视频亚洲| 一本色道久久88亚洲综合88| 老司机一区二区三区| 欧美三级在线| 激情久久婷婷| 欧美一区二区三区免费观看| 欧美a级片网| 欧美在线观看网址综合| 欧美激情欧美狂野欧美精品| 国产精品激情| 99精品欧美一区二区三区综合在线| 欧美一区免费视频| 亚洲美女精品久久| 美国十次了思思久久精品导航| 国产精品永久入口久久久| 亚洲少妇一区| 99视频精品在线| 欧美日韩大陆在线| 99视频超级精品| 在线一区二区三区四区五区| 欧美日本成人| 亚洲精品久久久久久久久久久| 麻豆91精品| 欧美紧缚bdsm在线视频| 一本久久综合亚洲鲁鲁| 日韩手机在线导航| 国产精品免费区二区三区观看| 亚洲综合日韩在线| 亚洲免费伊人电影在线观看av| 国产日韩一区二区三区| 久久亚洲免费| 欧美激情亚洲视频| 午夜精品成人在线视频| 欧美淫片网站| 亚洲欧洲日韩综合二区| 亚洲欧洲日产国产综合网| 欧美视频精品在线观看| 久久久精品久久久久| 欧美成人资源网| 久久久欧美精品sm网站| 欧美精品午夜视频| 久久成人精品电影| 欧美视频一区二| 最新亚洲视频| 在线观看精品视频| 亚洲欧美国产精品专区久久| 136国产福利精品导航网址应用 | 国产日韩欧美三级| 亚洲成人在线视频播放 | 国产伦精品一区二区三区视频黑人 | 一区二区三区四区国产| 伊人婷婷欧美激情| 99视频精品全部免费在线| 1024亚洲| 老司机一区二区| 免费观看亚洲视频大全| 国产麻豆午夜三级精品| 亚洲一区二区影院| 亚洲综合99| 国产精品网红福利| 一本色道久久综合亚洲精品不 | 一区二区三区四区五区在线| 亚洲电影在线看| 久久精品视频在线播放| 久久福利影视| 亚洲高清在线播放| 免费成人在线观看视频| 亚洲国产精品免费| 一区二区不卡在线视频 午夜欧美不卡在 | 伊人成人开心激情综合网| 欧美亚洲综合久久| 老司机午夜精品视频| 亚洲国产成人精品女人久久久 |