Fun House Submit page summary time limit: 1 sec Memory limit: 128 mb submitted: 498 solved: 176 Description
American Carnival Makers Inc. (ACM) has a long history of designing rides and attractions. One of their more popular attractions are a fun house that includes a room of mirrors. Their trademark is to set up the room so then looking forward from the entry door, the exit door appears to be direct Ly ahead. However, the room has double-sided mirrors placed throughout at degree. So, the exit door can is on any of the walls of the room. The set designer always places the entry and mirrors, but can never seem to is bothered to place the exit door. One of your jobs as part of the construction crew was to determine the placement of the "exit door for" room given an ori Ginal design.
The final diagram for a sample room is given below. The asterisk (*) marks the entry way, lower case X ' s mark the walls, the mirrors are to given by the forward and backward SLA SH characters (/and \), open spaces with no visual obstructions are marked by periods (.), and the desired placement of T He exit are marked with an ampersand (&). In the input diagram, there are an ' x ' ' & ', since the exit has not yet been. You are need to alter the "input diagram by replacing" proper ' X ' with a ' & ' to identify the exit. Note so entrances and exits can appear on any of the walls (although never a corner), and which it is physically impossib Le for the "exit" to be the same as the entrance. (You don ' t need to understand why.), although it may be fun to.
Xxxxxxxxxxx
X.. /.. \...x
x..../....x
*.. /......x
x.........x
Xxxxxx&xxxx
Input
Each room would be preceded by two integers, W and L, where 5≤w≤20 is the width of the room including the border walls And 5≤l≤20 is the length of the room including the border walls. Following the specification of W and L are L additional lines containing the room diagram ERs from the alphabet: {*,x,.,/,\}. The perimeter would always be comprised of walls, except for one asterisk (*) which marks the entrance; The exit is not (yet) marked. Line A and two zeros indicates the end of input data.
Output
For the all test case, the the ' the ', ' the ' the ' the ' the ' contain ' word, house, followed by a spaces and then an integer that identifies t He given fun house sequentially. Following that should is a room diagram which includes the proper placement of the exit door, as marked by a ampersand (& amp;).
Sample Input
One 6
xxxxxxxxxxx
x. /.. \...x
x..../....x
*. /......x
x.........x
xxxxxxxxxxx
5 5
xxxxx
*...x
x...x
x...x
xxxxx
5 5
xxxxx
x./\x
*./.x
x.. \x
xxxxx
6 6
xxx*xx
x/...x
x....x
x/./.x
x\./.x xxxxxx Xxxxxxxxxx
x.../\...x
x........x
x........x
x.../\. \x
*...\/. /x
x........x
x........x
x...\/...x
xxxxxxxxxx
0 0
Sample Output
House 1
xxxxxxxxxxx
x. /.. \...x
x..../....x
*. /......x
x.........x
xxxxxx&xxxx House
2
xxxxx
*...&
x...x
x...x
XXXXX House
3
xxxxx
x./\x
*./.x
x. \&
xxxxx House
4
xxx*xx
x/...x
x....x
x/./.&
x\./.x xxxxxx House
5
xxxxxxxxxx
x.../\...x
x........x
x........x
&.../\. \x
*...\/. /x
x........x
x........x
x...\/...x
xxxxxxxxxx
Hint
In both Java and C + + backslash character (\) has special meaning as an escape character within character and string Li Terals. You are must use the combination \ to express a single backslash within a character or string literal source code.
Source
There is a map, from a bursts light, if you touch the mirror light will reflect, find out where the light eventually shot
The idea of solving problems: DFS can
#include <iostream> #include <cstdio> #include <cstring> #include <string> #includ
E <algorithm> #include <map> #include <cmath> #include <set> #include <stack> #include <queue> #include <vector> #include <bitset> #include <functional> usin
G namespace Std;
#define LL-long const int INF = 0X3F3F3F3F;
Char ch[30][30];
int dir[4][2]={{1,0},{0,1},{0,-1},{-1,0}};
int n,m;
void Dfs (int x,int y,int d) {if (ch[x][y]== ' x ') {ch[x][y]= ' & '; if (ch[x][y]== ' * ' | | ch[x][y]== '. ')
DFS (X+DIR[D][0],Y+DIR[D][1],D);
else if (ch[x][y]== '/') {if (d==0) DFS (dir[2][0]+x,y+dir[2][1],2);
else if (d==1) DFS (dir[3][0]+x,dir[3][1]+y,3);
else if (d==2) DFS (dir[0][0]+x,dir[0][1]+y,0);
else Dfs (dir[1][0]+x,dir[1][1]+y,1);
else {if (d==0) DFS (dir[1][0]+x,dir[1][1]+y,1);
else if (d==1) DFS (dir[0][0]+x,dir[0][1]+y,0); else if (d==2) DFS (dir[3][0]+x,dir[3][1]+y, 3);
else Dfs (dir[2][0]+x,y+dir[2][1],2);
int main () {int cas=0;
while (~SCANF ("%d%d", &m,&n) && (n+m)) {int x,y;
for (int i=1;i<=n;i++) {scanf ("%s", ch[i]+1);
for (int j=1;j<=m;j++) if (ch[i][j]== ' * ') {x=i,y=j}
} if (x==1) DFS (x,y,0);
if (x==n) DFS (x,y,3);
if (y==1) DFS (x,y,1);
if (y==n) DFS (x,y,2);
printf ("House%d\n", ++cas);
for (int i=1;i<=n;i++) printf ("%s\n", ch[i]+1);
return 0; }