题目传送门

 /*
题意:光线从 '*' 发射,遇到 '/' 或 '\' 进行反射,最后射到墙上,将 '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. document.documentElement和document.body的区别

    网页中获取滚动条卷去部分的高度,可以通过 document.body.scrollTop 来获取,比如使div跟着滚动条滚动: <div id="div" style=&qu ...

  2. 手动安装ubuntu视频播放器插件的方法

    新安装的ubuntu14.04在浏览器里面都不能看视频,提示缺少播放器插件,而且有一个安装的按钮,但是点击之后往往提示找不到,这就要手动安装了.第一步:首先运行一下更新命令吧sudo apt-get ...

  3. iOS开发——底层OC篇&运行时常用

    运行时常用 什么是Runtime(前面的文章已经说的很清楚了,这里就简单的介绍一下) 我们写的代码在程序运行过程中都会被转化成runtime的C代码执行,例如[target doSomething]; ...

  4. C#内部类

    http://blog.csdn.net/yanghua_kobe/article/details/6685222 在<Java编程思想>中花了一章的篇幅介绍,内部类的相关特性.而在C#的 ...

  5. index and polymorphic

    http://guides.rubyonrails.org/association_basics.html#polymorphic-associations class CreateStars < ...

  6. hMailServer+foxmail配置局域网邮件服务器

    1.下载hMailServer并安装,请参考以下网址 https://www.hmailserver.org 2.安装foxmail,官网如下: http://www.foxmail.com/ 3.配 ...

  7. BASH相关

    颜色 http://www.cnblogs.com/lr-ting/archive/2013/02/28/2936792.html http://segmentfault.com/q/10100000 ...

  8. IDEA 14快捷键

    1.ctrl+alt+左箭头.右箭头:返回到上次浏览的代码处(相当于Eclipse的alt+左右箭头) 编辑类: Ctrl+Space 基本代码实例(类.方法.变量) Ctrl + Shift + S ...

  9. Kmin

    Kmin of Array [本文链接] http://www.cnblogs.com/hellogiser/p/kmin-of-array.html [代码]  C++ Code  12345678 ...

  10. 43. 动态规划求解n个骰子的点数和出现概率(或次数)[Print sum S probability of N dices]

    [题目] 把N个骰子扔在地上,所有骰子朝上一面的点数之和为S.输入N,打印出S的所有可能的值出现的概率. [分析] 典型的动态规划题目. 设n个骰子的和为s出现的次数记为f(n,s),其中n=[1-N ...