题目传送门

 /*
题意:光线从 '*' 发射,遇到 '/' 或 '\' 进行反射,最后射到墙上,将 '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. Unity3D开发之NGUI点击事件穿透响应处理

    http://www.xuebuyuan.com/1936292.html 在使用NGUI 开发2D项目的时候,发现了一个问题,就是如果点出一个菜单,然后点击菜单上面的按钮的时候就会使得按钮下面的物品 ...

  2. 新鲜出炉的百度js面试题

    (文章是从我的个人主页上粘贴过来的,大家也可以访问我的主页 www.iwangzheng.com) 最近两位同学入职百度,带回来的笔试题基本上毫无悬念,不过有一个小题看到让人忍不住笑出声来,真的很无聊 ...

  3. jquery.fileupload.js 杂记

    通过$your_jq_dom.fileupload({},donf:function...,fail:function..., ...) 得到的只是一个支持上传的控件,当然绑定了各种事件. 传参给ur ...

  4. TokuDB的特点验证 - billy鹏

    TokuDB的特点验证 - billy鹏 时间 2014-03-03 14:28:00  博客园_billy鹏的足迹原文  http://www.cnblogs.com/billyxp/p/35674 ...

  5. dell idrac8 部署操作系统的方法

    1,打开虚拟控制台 2,“虚拟介质”->“连接虚拟介质”->“映射虚拟介质到CD”->(选择要安装的镜像文件)->“Map device” 3, “next boot”-> ...

  6. Linux运维

    概要:http://os.51cto.com/art/201312/423616.htm 论坛: http://www.linux360.cn/ https://www.centos.bz/ http ...

  7. TestPointer

     C++ Code  12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 ...

  8. php 字符串负值判断

    2014年9月9日 11:54:54 $a = '-1'; $b = (int)$a; $c = is_numeric($a); if ($a) { echo 1; //echo 1 } else { ...

  9. codeforces B. Color the Fence 解题报告

    题目链接:http://codeforces.com/problemset/problem/349/B 题目意思:给定v升的颜料和9个需要花费ad 升的颜料,花费ad 升的颜料意味着得到第d个数字,现 ...

  10. July 20th, Week 30th Wednesday, 2016

    Learn from yesterday, live for today, and hope for tomorrow. 借鉴昨天,活着当下,憧憬未来. Yesterday is the past, ...