SDUT3184 Fun House(模拟)
来源:互联网 发布:javascript主要用途 编辑:程序博客网 时间:2024/06/05 03:11
Fun House
Time Limit: 1000MS Memory limit: 65536K
题目描述
American Carnival Makers Inc. (ACM) has a long history of designing rides and attractions. One of their more popular attractions is a fun house that includes a room of mirrors. Their trademark is to set up the room so that when looking forward from the entry door, the exit door appears to be directly ahead. However, the room has double-sided mirrors placed throughout at 45 degree angles. So, the exit door can be on any of the walls of the room. The set designer always places the entry and mirrors, but can never seem to be bothered to place the exit door. One of your jobs as part of the construction crew is to determine the placement of the exit door for the room given an original design.
The final diagram for a sample room is given below. The
x../..\...x
x..../....x
*../......x
x.........x
xxxxxx&xxxx
输入
输出
示例输入
11 6xxxxxxxxxxxx../..\...xx..../....x*../......xx.........xxxxxxxxxxxx5 5xxxxx*...xx...xx...xxxxxx5 5xxxxxx./\x*./.xx..\xxxxxx6 6xxx*xxx/...xx....xx/./.xx\./.xxxxxxx10 10xxxxxxxxxxx.../\...xx........xx........xx.../\..\x*...\/../xx........xx........xx...\/...xxxxxxxxxxx0 0
示例输出
HOUSE 1xxxxxxxxxxxx../..\...xx..../....x*../......xx.........xxxxxxx&xxxxHOUSE 2xxxxx*...&x...xx...xxxxxxHOUSE 3xxxxxx./\x*./.xx..\&xxxxxHOUSE 4xxx*xxx/...xx....xx/./.&x\./.xxxxxxxHOUSE 5xxxxxxxxxxx.../\...xx........xx........x&.../\..\x*...\/../xx........xx........xx...\/...xxxxxxxxxxx
提示
来源
示例程序
#include<iostream>#include<algorithm>#include<stdio.h>#include<string.h>#include<stdlib.h>#include<queue>#include<stack>#include<vector>#include<math.h>#include<map>#define inf 0x3f3f3f3f#define LL long longusing namespace std;struct node{ int x; int y;};char mm[31][31];int n,m;void BFS(int ii,int jj,int jx,int jy){ queue<node>q; while(!q.empty()) { q.pop(); } struct node t,f; t.x = ii; t.y = jj; q.push(t); while(!q.empty()) { t = q.front(); q.pop(); f.x = t.x + jx; f.y = t.y + jy; if(mm[f.x][f.y] == 'x') { mm[f.x][f.y] = '&'; break; } else if(mm[f.x][f.y] == '/') { if(jx == 0 && jy == 1) { jx = -1; jy = 0; } else if(jx == 0 && jy == -1) { jx = 1; jy = 0; } else if(jx == 1 && jy == 0) { jx = 0; jy = -1; } else if(jx == -1 && jy == 0) { jx = 0; jy = 1; } } else if(mm[f.x][f.y] == '\\') { if(jx == 0 && jy == 1) { jx = 1; jy = 0; } else if(jx == 0 && jy == -1) { jx = -1; jy = 0; } else if(jx == 1 && jy == 0) { jx = 0; jy = 1; } else if(jx == -1 && jy == 0) { jx = 0; jy = -1; } } q.push(f); }}int main(){ int kk = 0; while(scanf("%d%d",&m,&n)!=EOF) { if(n == 0 && m == 0) { break; } int xx,yy; for(int i=0; i<n; i++) { scanf("%s",mm[i]); for(int j=0; j<m; j++) { if(mm[i][j] == '*') { xx = i; yy = j; break; } } } if(xx == 0) { BFS(xx,yy,1,0); } else if(xx == n-1) { BFS(xx,yy,-1,0); } else if(yy == 0) { BFS(xx,yy,0,1); } else if(yy == m-1) { BFS(xx,yy,0,-1); } printf("HOUSE %d\n",++kk); for(int i=0; i<n; i++) { printf("%s\n",mm[i]); } } return 0;}
- SDUT3184 Fun House(模拟)
- Fun House
- csu 1562: Fun House (DFS)
- CSU 1562 Fun House(直线搜索)
- 1562: Fun House
- 1562:Fun House
- CSU 1562Fun House
- csu 1562 Fun House
- CSU1562 Fun House
- CSU1562-Fun House
- CSU 1562 Fun House
- Fun House CSU
- CSU 1562 — Fun House
- HDU-#4737 A Bit Fun(模拟)
- hdoj 1331 Function Run Fun(模拟)
- Codeforces548B Mike and Fun (模拟)
- HDU 5538 House Building (简单模拟)
- 【玲珑学院OJ1065】Just for Fun(模拟)
- jqueryMobile页面跳转ajax载入与缓存问题
- Web验证码实现机制
- File 里面的flush()和close()
- jquery multiselect动态加option,需要调用refresh方法才能刷新option
- C++:sizeof问题
- SDUT3184 Fun House(模拟)
- 黑马程序员--IOS学习笔记(封装、继承、多态)
- KMP算法详解
- Python实用库收集
- openwrt lan wan配置
- 工作周报036
- oracle安装之check if the DISPLAY variable is set错误
- LoadRunner获取当前时间
- mvc框架初识