模拟 CSU 1562 Fun House
/*
题意:光线从 '*' 发射,遇到 '/' 或 '\' 进行反射,最后射到墙上,将 '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的更多相关文章
- csu 1312 榜单(模拟题)
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1312 1312: 榜单 Time Limit: 1 Sec Memory Limit: 128 ...
- 【模拟】CSU 1807 最长上升子序列~ (2016湖南省第十二届大学生计算机程序设计竞赛)
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1807 题目大意: 给你一个长度为N(N<=105)的数列,数列中的0可以被其他数 ...
- 【模拟】【数学】CSU 1803 2016 (2016湖南省第十二届大学生计算机程序设计竞赛)
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1803 题目大意: 给定n,m(n,m<=109)1<=i<=n,1& ...
- csu - 1536: Bit String Reordering (模拟)
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1536 不知道为何怎么写都写不对. 这题可以模拟. 虽然题目保证一定可以从原串变成目标串,但是不一定 ...
- CSU 1862 The Same Game(模拟)
The Same Game [题目链接]The Same Game [题目类型]模拟 &题解: 写这种模拟题要看心态啊,还要有足够的时间,必须仔细读题,一定要写一步,就调试一步. 这题我没想到 ...
- CSU 1857 Crash and Go(relians)(模拟)
Crash and Go(relians) [题目链接]Crash and Go(relians) [题目类型]模拟 &题解: 这就是要严格的按照题意说的模拟就好了,也就是:每次添加进来一个圆 ...
- csu 1549: Navigition Problem(几何,模拟)
1549: Navigition Problem Time Limit: 1 Sec Memory Limit: 256 MBSubmit: 305 Solved: 90[Submit][Stat ...
- CSU 1023 修路(二分+模拟)
前段时间,某省发生干旱,B山区的居民缺乏生活用水,现在需要从A城市修一条通往B山区的路.假设有A城市通往B山区的路由m条连续的路段组成,现在将这m条路段承包给n个工程队(n ≤ m ≤ 300).为了 ...
- csu - 1537: Miscalculation (模拟题)
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1537 因为给出的式子是必定合法的,只要用两个栈分别保存符号和数字.算出答案后和从左至右算的答案比对 ...
随机推荐
- Stockbroker Grapevine(floyd)
Stockbroker Grapevine Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 28231 Accepted: ...
- quick cocos 的scheduler 定时器
cocos2dx原生lua对于定时器的写法: 1.每帧调用: void scheduleUpdateWithPriority(int priority) void scheduleUpdateWith ...
- Docker大行其道—初识
导读 随着分布式.云计算.大数据的火热爆发,大量的云计算集群出现,光凭计算机硬件配置的已经无法再次一较高下,虚拟化成为其中最核心的技术.虚拟化既可以通过硬件模拟,也可以通过操作系统层面去实现,近年来热 ...
- 滚动光效shader
Shader "Custom/LightMove" { Properties { _MainTex ("Base (RGB)", 2D) = "whi ...
- Leetcode 之Validate Binary Search Tree(53)
判断是否是有效的二叉搜索树,即左子树的值小于根结点,右子树的值大于根结点.可以采用递归的方式来完成,递归时如何 传递有效的参数与根结点进行比较,是此题的难点. bool isValidBST(Tree ...
- ZeroMQ(java)之Router/Dealer模式
本教程转自:http://blog.csdn.net/kobejayandy/article/details/20163527 在开始之前先把guid里面提到的几个ZeroMQ的特性列一下吧: (1) ...
- 静态资源[org.springframework.web.servlet.PageNotFound]
springmvc 无法访问js.css.jpg等资源文件,tomcat启动报警告如下 [org.springframework.web.servlet.PageNotFound] - No mapp ...
- Linux生产服务器Shell脚本分享
Linux生产服务器Shell脚本分享 2012-6-6 86市场网 linux 作为一名Linux/unix系统管理员,我经常遇到人问这个问题:shell能做什么?PHP这么强大,为什么不用PHP来 ...
- How to: Set up Openswan L2TP VPN Server on CentOS 6
Have you ever wanted to set up your own VPN server? By following the steps below, you can set up you ...
- ubuntu14.04安装chrome
到https://www.google.com/chrome/browser/desktop/index.html可下载指定版本的deb文件. 32bit: wget https://dl.googl ...