题目传送门

 /*
题意:光线从 '*' 发射,遇到 '/' 或 '\' 进行反射,最后射到墙上,将 'x' 变成 '&'
模拟:仔细读题,搞清楚要做什么,就是i,j的移动,直到撞到墙,模拟一下一次AC,不要被题目吓怕了:)
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <stack>
#include <cmath>
#include <cstring>
#include <vector>
using namespace std; const int MAXN = 1e4 + ;
const int INF = 0x3f3f3f3f;
char g[][]; int main(void) //CSU 1562 Fun House
{
//freopen ("B.in", "r", stdin); int n, m, cas = ;
while (scanf ("%d%d", &m, &n) == )
{
if (n == && m == ) break; for (int i=; i<n; ++i)
{
scanf ("%s", &g[i]);
} printf ("HOUSE %d\n", ++cas); int sx = -, sy = -;
int num = ;
for (int i=; i<n; ++i)
{
for (int j=; j<m; ++j)
{
if (g[i][j] == '*')
{
if (j == ) num = ;
else if (j == m-) num = ;
else if (i == ) num = ;
else if (i == n-) num = ;
sx = i; sy = j;
break;
}
}
} while ()
{
if (num == )
{
++sy;
if (g[sx][sy] == '/') num = ;
else if (g[sx][sy] == '\\') num = ;
else if (g[sx][sy] == 'x')
{
g[sx][sy] = '&'; break;
}
}
else if (num == )
{
--sy;
if (g[sx][sy] == '/') num = ;
else if (g[sx][sy] == '\\') num = ;
else if (g[sx][sy] == 'x')
{
g[sx][sy] = '&'; break;
}
}
else if (num == )
{
++sx;
if (g[sx][sy] == '/') num = ;
else if (g[sx][sy] == '\\') num = ;
else if (g[sx][sy] == 'x')
{
g[sx][sy] = '&'; break;
}
}
else if (num == )
{
--sx;
if (g[sx][sy] == '/') num = ;
else if (g[sx][sy] == '\\') num = ;
else if (g[sx][sy] == 'x')
{
g[sx][sy] = '&'; break;
}
}
} for (int i=; i<n; ++i)
{
for (int j=; j<m; ++j)
{
printf ("%c", g[i][j]);
}
puts ("");
}
} return ;
} /*
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
*/

模拟 CSU 1562 Fun House的更多相关文章

  1. csu 1312 榜单(模拟题)

    http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1312 1312: 榜单 Time Limit: 1 Sec  Memory Limit: 128 ...

  2. 【模拟】CSU 1807 最长上升子序列~ (2016湖南省第十二届大学生计算机程序设计竞赛)

    题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1807 题目大意: 给你一个长度为N(N<=105)的数列,数列中的0可以被其他数 ...

  3. 【模拟】【数学】CSU 1803 2016 (2016湖南省第十二届大学生计算机程序设计竞赛)

    题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1803 题目大意: 给定n,m(n,m<=109)1<=i<=n,1& ...

  4. csu - 1536: Bit String Reordering (模拟)

    http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1536 不知道为何怎么写都写不对. 这题可以模拟. 虽然题目保证一定可以从原串变成目标串,但是不一定 ...

  5. CSU 1862 The Same Game(模拟)

    The Same Game [题目链接]The Same Game [题目类型]模拟 &题解: 写这种模拟题要看心态啊,还要有足够的时间,必须仔细读题,一定要写一步,就调试一步. 这题我没想到 ...

  6. CSU 1857 Crash and Go(relians)(模拟)

    Crash and Go(relians) [题目链接]Crash and Go(relians) [题目类型]模拟 &题解: 这就是要严格的按照题意说的模拟就好了,也就是:每次添加进来一个圆 ...

  7. csu 1549: Navigition Problem(几何,模拟)

    1549: Navigition Problem Time Limit: 1 Sec  Memory Limit: 256 MBSubmit: 305  Solved: 90[Submit][Stat ...

  8. CSU 1023 修路(二分+模拟)

    前段时间,某省发生干旱,B山区的居民缺乏生活用水,现在需要从A城市修一条通往B山区的路.假设有A城市通往B山区的路由m条连续的路段组成,现在将这m条路段承包给n个工程队(n ≤ m ≤ 300).为了 ...

  9. csu - 1537: Miscalculation (模拟题)

    http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1537 因为给出的式子是必定合法的,只要用两个栈分别保存符号和数字.算出答案后和从左至右算的答案比对 ...

随机推荐

  1. html 的table tr td的使用

    cellspacing 属性规定单元格之间的空间. cellpadding 属性规定单元边沿与其内容之间的空白. border 简写属性在一个声明设置所有的边框属性. border 用在table属性 ...

  2. lucene搜索方式(query类型)

    Lucene有多种搜索方式,可以根据需要选择不同的方式. 1.词条搜索(单个关键字查找) 主要对象是TermQuery 调用方式如下: Term term=new Term(字段名,搜索关键字);Qu ...

  3. 对target="framename"的理解(实现分页的demo)

    先上图,说明一下我主要想实现什么功能. 一.演示图 演示首页: 演示内容页(包括按钮切换页+模板内容页): 演示首页到演示内容页的一个演变过程:

  4. HDOJ 1864 最大报销额(01背包)

    http://acm.hdu.edu.cn/showproblem.php?pid=1864 最大报销额 Time Limit: 1000/1000 MS (Java/Others)    Memor ...

  5. /var/lock/subsys作用

    转自: http://sunxiaqw.blog.163.com/blog/static/9906543820111184422807/ 关于/var/lock/subsys目录 总的来说,系统关闭的 ...

  6. Linux awk命令详解??????????(研究)

    http://blog.chinaunix.net/uid-25120309-id-3801250.html 一.  AWK 说明  awk是一种编程语言,用于在linux/unix下对文本和数据进行 ...

  7. TestPointer

     C++ Code  12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 ...

  8. 用RPM包安装MySQL的默认安装路径问题

    在安装PHP时候要对一些配置选项进行设置,其中就有:--with-mysql[=DIR]:包含MySQL扩展,[=DIR]指定mysql安装目录,省略[=DIR]则为默认位置/usr--with-my ...

  9. iOS的runtime(转)

    1. 什么是runtime 运行时刻是指一个程序在运行(或者在被执行)的状态.也就是说,当你打开一个程序使它在电脑上运行的时候,那个程序就是处于运行时刻.在一些编程语言中,把某些可以重用的程序或者实例 ...

  10. 【HTTP协议】响应头中的Content-Length和Transfer-Encoding

    来源: http://blog.csdn.net/superhosts/article/details/8737434 http://bbs.csdn.net/topics/390384017 对于h ...