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

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.
這道題是簡單的BFS由于 對C++的不熟悉導致比賽的時候 怎么寫一直猶豫不決剛才搞了搞C++終于寫出來了 原來可以這樣寫的

#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) 評論(0)  編輯 收藏 引用
<2009年1月>
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

常用鏈接

留言簿(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>
            永久555www成人免费| 榴莲视频成人在线观看| 欧美91精品| 欧美一二三视频| 亚洲一级高清| 亚洲九九精品| 久久久久国内| 在线视频精品一| 国产精品va在线播放我和闺蜜| 欧美一区二区国产| 欧美在线免费一级片| 亚洲欧美日韩另类| 国产精品激情电影| 国产精品看片你懂得| 欧美日韩一级大片网址| 国产精品男gay被猛男狂揉视频| 欧美久久视频| 麻豆国产精品va在线观看不卡 | 亚洲视频一区| 亚洲福利在线看| 日韩亚洲欧美一区二区三区| 在线日韩中文| 亚洲一二三四久久| 亚洲欧美日韩国产一区二区| 性做久久久久久久久| 久久经典综合| 久久婷婷亚洲| 欧美a级片网站| 久久爱另类一区二区小说| 99re热精品| 欧美在线1区| 久久午夜国产精品| 欧美+亚洲+精品+三区| 亚洲国产cao| 亚洲图片欧洲图片日韩av| 亚洲每日在线| 午夜久久一区| 欧美国产日韩在线| 夜夜爽av福利精品导航| 欧美专区日韩视频| 欧美一区二区三区的| 久久精品伊人| 欧美激情四色| 欲香欲色天天天综合和网| 99精品国产一区二区青青牛奶| 久久国产夜色精品鲁鲁99| 欧美福利精品| 久久精品91久久香蕉加勒比| 欧美极品影院| 亚洲香蕉网站| 欧美日韩精品在线播放| 国产视频综合在线| 欧美一区二区三区啪啪| 亚洲国产va精品久久久不卡综合| 夜夜爽av福利精品导航| 久久久久久久精| 国产亚洲精品bt天堂精选| 亚洲精品视频免费观看| 亚洲免费久久| 亚洲精品免费观看| 亚洲欧美一区二区精品久久久 | 欧美制服第一页| 欧美激情一区在线| 亚洲欧美日韩中文播放| 欧美国产日韩亚洲一区| 国产欧美精品在线播放| 日韩天堂在线观看| 久久蜜臀精品av| 亚洲一区二区三区免费视频| 亚洲一区二区三区免费观看| 欧美顶级少妇做爰| 激情欧美一区二区三区| 久久网站免费| 久久国产精品72免费观看| 国产一区免费视频| 欧美一区二区女人| 激情综合视频| 欧美在线你懂的| 亚洲综合丁香| 国产精品视频成人| 亚洲欧美日韩一区| 99日韩精品| 欧美日韩一区二| 亚洲视频二区| 亚洲精一区二区三区| 欧美成人自拍视频| 99精品欧美一区| 亚洲高清三级视频| 亚洲黄色一区| 国产精品成人aaaaa网站| 亚洲婷婷免费| 一区二区免费看| 国产精品久久久久免费a∨大胸| 中文日韩在线视频| 日韩亚洲欧美精品| 欧美色视频日本高清在线观看| 亚洲另类视频| 一区二区三区高清视频在线观看| 欧美四级伦理在线| 翔田千里一区二区| 在线一区二区三区做爰视频网站| 欧美日韩成人一区二区| 亚洲一区二区3| 先锋影音久久久| 亚洲国产欧美日韩精品| 日韩视频在线观看一区二区| 国产精一区二区三区| 亚洲高清影视| 国产精品成人在线| 男同欧美伦乱| 欧美日韩精品久久久| 久久综合九色九九| 欧美日韩精品一本二本三本| 久久久久久夜精品精品免费| 免费亚洲一区二区| 久久福利视频导航| 欧美高清在线一区二区| 欧美日韩不卡| 在线亚洲成人| 国产一区二区高清| 一本不卡影院| 在线欧美一区| 欧美诱惑福利视频| 日韩视频在线观看| 久久只精品国产| 一本大道久久a久久精品综合| 香蕉成人久久| 艳妇臀荡乳欲伦亚洲一区| 欧美制服丝袜第一页| 亚洲欧美日韩中文播放| 亚洲无亚洲人成网站77777| 亚洲婷婷在线| 在线欧美亚洲| 久久国产精品黑丝| 亚洲一区二区三区国产| 欧美激情第1页| 久久久久网址| 国产日韩欧美一区在线 | 欧美成人免费全部观看天天性色| 国产欧美日韩不卡免费| 亚洲精品久久在线| 日韩午夜精品视频| 久久久久久久欧美精品| 久久一区二区三区国产精品| 欧美午夜视频| 亚洲一级黄色| 亚洲视频导航| 国产精品视频一区二区高潮| 亚洲激情在线观看| 91久久夜色精品国产网站| 欧美在线播放| 免费在线观看成人av| 国产欧美日韩一区| 欧美在线免费观看视频| 久久福利一区| 亚洲电影av| 久久亚洲精选| 亚洲每日更新| 一本大道久久a久久精品综合| 国产精品videosex极品| 日韩亚洲欧美中文三级| 亚洲欧美成人一区二区三区| 欧美视频手机在线| 欧美一区91| 久久中文在线| 在线视频免费在线观看一区二区| 欧美日韩亚洲另类| 亚洲女同同性videoxma| 亚洲欧美国产三级| 狠狠久久亚洲欧美| 久久另类ts人妖一区二区| 亚洲国产精品一区制服丝袜| 91久久中文| 欧美精品日韩一区| 亚洲精品色图| 亚洲欧美国产高清va在线播| 国产精品久久久一本精品| 亚洲一二三级电影| 欧美伊人久久| 伊大人香蕉综合8在线视| 麻豆精品视频| 亚洲精选视频在线| 久久精品视频在线观看| 亚洲国产裸拍裸体视频在线观看乱了 | 久久综合九九| 一区二区高清| 亚洲美女av网站| 欧美视频日韩视频| 亚洲福利专区| 99一区二区| 久久久久国产精品一区三寸| 午夜精品视频一区| 一区二区三区欧美亚洲| 欧美在线一二三四区| 一区二区三区四区国产精品| 欧美承认网站| 日韩写真视频在线观看| 欧美自拍偷拍午夜视频| 国产亚洲欧洲| 亚洲在线网站|