手癌!日常手癌!被自己气死!

 #include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>
#define maxn 25
using namespace std;
const int dx[]={-,,,},dy[]={,,-,};
struct point{
int x,y;
int time;
}start;
char map[maxn][maxn];
int v[maxn][maxn];
int n,m,ans;
int check(point next){
if (map[next.x][next.y]=='*' || next.x< || next.x>=n || next.y< || next.y>=m || v[next.x][next.y]) return ;
else return ;
}
int bfs(point start){
queue<point> Q;
Q.push(start);
v[start.x][start.y]=;
while (!Q.empty()){
point pre=Q.front();
Q.pop();
if (map[pre.x][pre.y]=='T'){
return pre.time;
}
for (int i=;i<;i++){
point next;
next.x=pre.x+dx[i];
next.y=pre.y+dy[i];
next.time=pre.time+;
if (check(next)) continue;
if (map[next.x][next.y]=='.' || map[next.x][next.y]=='T'){
Q.push(next);
v[next.x][next.y]=;
}
else if (map[next.x][next.y]=='|' && !(pre.time&) || map[next.x][next.y]=='-' && (pre.time&)){ //表示横着走
if (i>){
next=pre;
next.time++;
Q.push(next);
continue;
}
next.x+=dx[i];
if (check(next)) continue;
Q.push(next);
v[next.x][next.y]=;
}
else { // 表示竖着走
if (i<){
next=pre;
next.time++;
Q.push(next);
continue;
}
next.y+=dy[i];
if (check(next)) continue;
Q.push(next);
v[next.x][next.y]=;
}
}
}
}
int main(){
while (cin >> n >> m){
for (int i=;i<n;i++){
for (int j=;j<m;j++){
cin >> map[i][j];
if (map[i][j]=='S'){
start.x=i;
start.y=j;
start.time=;
}
}
}
memset(v,,sizeof(v));
ans=bfs(start);
cout << ans << endl;
}
return ;
}

hdoj1180 诡异的楼梯(bfs+奇偶判断)的更多相关文章

  1. hdu 1180诡异的楼梯(bfs)

    诡异的楼梯 Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other) Total Submis ...

  2. hdu 1180 诡异的楼梯 (bfs)

    诡异的楼梯 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others) Total Sub ...

  3. hdu1180 诡异的楼梯 bfs

    题目链接:http://icpc.njust.edu.cn/Problem/Hdu/1180/ 题目和不同的bfs有个不同的地方就是存在横着的或者竖着的楼梯,楼梯每过一个时刻就改变一次横竖的走向,人可 ...

  4. hdu - 1180 诡异的楼梯 (bfs+优先队列)

    http://acm.hdu.edu.cn/showproblem.php?pid=1180 注意点就是楼梯是在harry移动完之后才会改变方向,那么只要统计到达这个点时间奇偶性,就可以知道当前楼梯是 ...

  5. hdu 1180:诡异的楼梯(BFS广搜)

    诡异的楼梯 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)Total Subm ...

  6. HDU 1180 诡异的楼梯(超级经典的bfs之一,需多回顾)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1180 诡异的楼梯 Time Limit: 2000/1000 MS (Java/Others)     ...

  7. HDU 1180 诡异的楼梯【BFS/楼梯随时间变化】

    诡异的楼梯 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) Total Submis ...

  8. HDU 1180 诡异的楼梯(BFS)

    诡异的楼梯 Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status ...

  9. 诡异的楼梯(bfs)hdu1180

    诡异的楼梯 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submiss ...

随机推荐

  1. Response.Redirect原理图解

  2. 2018.07.23 洛谷P4097 [HEOI2013]Segment(李超线段树)

    传送门 给出一个二维平面,给出若干根线段,求出x" role="presentation" style="position: relative;"&g ...

  3. 数塔问题-hdu-2084(dp)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2084 思路:要求从顶到底的最大值,可以反过来考虑,从底部向上. 只有下面一行的最大值确定,这一行的最大 ...

  4. Django入门与实践-第24章:我的账户视图(完结)

    http://127.0.0.1:8000/settings/account/ #好的,那么,这部分将是我们最后的一个视图.之后,我们将专心来改进现有功能. #accounts/views.py fr ...

  5. 全国各地dns服务器列表

    211.103.13.101 江苏省无锡市 移动DNS服务器 211.136.28.231 北京市 移动DNS服务器 211.136.28.234 北京市 移动DNS服务器 211.136.28.23 ...

  6. * 结束Activity

    public class MainActivity extends Activity   {       @Override       public void onCreate(Bundle sav ...

  7. ics

    5.网分用法 时延测试: Format ->Delay Scale Ref -> AUTO SCALE Marker Search -> TRACKING[ON OFF]这样以后把M ...

  8. day3之函数的初始及进阶

    函数初始 函数的定义与调用 ''' def 函数名 (参数): 函数体 函数名:设定与变量相同 执行函数: 函数名() ''' 函数的返回值 # 函数返回值 return ''' 1.遇到return ...

  9. hdu5883 The Best Path 2016-09-21 21:31 92人阅读 评论(0) 收藏

    The Best Path Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) To ...

  10. oracle 游标实现多重循环

    declare -- Local variables here i integer; cursor c_province is select ds.swjg_dm from dm_swjg ds wh ...