模拟 HDOJ 4552 Running Rabbits
/*
模拟:看懂题意,主要是碰壁后的转向,笔误2次
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std; const int MAXN = 1e3 + ;
const int INF = 0x3f3f3f3f;
struct Rabbit
{
char c;
int d, s, t;
int x, y;
}r[]; int main(void) //HDOJ 4552 Running Rabbits
{
// freopen ("K.in", "r", stdin); int n;
while (scanf ("%d", &n) == )
{
if (n == ) break;
getchar ();
for (int i=; i<=; ++i)
{
scanf ("%c %d %d", &r[i].c, &r[i].s, &r[i].t);
if (r[i].c == 'E') r[i].d = ;
else if (r[i].c == 'N') r[i].d = ;
else if (r[i].c == 'W') r[i].d = ;
else r[i].d = ;
getchar ();
}
int k; scanf ("%d", &k);
r[].x = r[].y = ; r[].x = r[].y = n; for (int i=; i<=k; ++i)
{
for (int j=; j<=; ++j)
{
if (r[j].d == )
{
if (r[j].y + r[j].s > n)
{
r[j].y = * n - (r[j].y + r[j].s);
r[j].d = ;
}
else r[j].y += r[j].s;
}
else if (r[j].d == )
{
if (r[j].x - r[j].s < )
{
r[j].x = + r[j].s - r[j].x;
r[j].d = ;
}
else r[j].x -= r[j].s;
}
else if (r[j].d == )
{
if (r[j].y - r[j].s < )
{
r[j].y = + r[j].s - r[j].y;
r[j].d = ;
}
else r[j].y -= r[j].s;
}
else if (r[j].d == )
{
if (r[j].x + r[j].s > n)
{
r[j].x = * n - (r[j].x + r[j].s);
r[j].d = ;
}
else r[j].x += r[j].s;
}
} if (r[].x == r[].x && r[].y == r[].y) swap (r[].d, r[].d);
else
{
if (i % r[].t == ) r[].d = (r[].d + ) % ;
if (i % r[].t == ) r[].d = (r[].d + ) % ;
}
} for (int i=; i<=; ++i) printf ("%d %d\n", r[i].x, r[i].y);
} return ;
}
模拟 HDOJ 4552 Running Rabbits的更多相关文章
- [模拟] hdu 4452 Running Rabbits
意甲冠军: 两个人在一个人(1,1),一个人(N,N) 要人人搬家每秒的速度v.而一个s代表移动s左转方向秒 特别值得注意的是假设壁,反弹.改变方向 例如,在(1,1),采取的一个步骤,以左(1,0) ...
- hdu 4452 Running Rabbits 模拟
Running RabbitsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- HDU4452 Running Rabbits
涉及知识点: 1. direction数组. 2. 一一映射(哈希). Running Rabbits Time Limit: 2000/1000 MS (Java/Others) Memory ...
- LPS HDOJ 4745 Two Rabbits
题目传送门 /* 题意:一只兔子顺时针跳,另一只逆时针跳,跳石头权值相等而且不能越过起点 LPS:这道就是LPS的应用,把环倍增成链,套一下LPS,然而并不能理解dp[i][i+n-2] + 1,看别 ...
- HDU 4452 Running Rabbits (模拟题)
题意: 有两只兔子,一只在左上角,一只在右上角,两只兔子有自己的移动速度(每小时),和初始移动方向. 现在有3种可能让他们转向:撞墙:移动过程中撞墙,掉头走未完成的路. 相碰: 两只兔子在K点整(即处 ...
- 【HDU 4452 Running Rabbits】简单模拟
两只兔子Tom和Jerry在一个n*n的格子区域跑,分别起始于(1,1)和(n,n),有各自的速度speed(格/小时).初始方向dir(E.N.W.S)和左转周期turn(小时/次). 各自每小时往 ...
- 模拟 HDOJ 5099 Comparison of Android versions
题目传送门 /* 题意:比较型号的大小 模拟:坑点在长度可能为5,此时设为'A' */ #include <cstdio> #include <algorithm> #incl ...
- 模拟 HDOJ 5095 Linearization of the kernel functions in SVM
题目传送门 /* 题意:表达式转换 模拟:题目不难,也好理解题意,就是有坑!具体的看测试样例... */ #include <cstdio> #include <algorithm& ...
- 模拟 HDOJ 5387 Clock
题目传送门 /* 模拟:这题没啥好说的,把指针转成角度处理就行了,有两个注意点:结果化简且在0~180内:小时13点以后和1以后是一样的(24小时) 模拟题伤不起!计算公式在代码内(格式:hh/120 ...
随机推荐
- mysql 之 Workbench的使用
mysql 之 Workbench的使用 (1)简介 MySQL Workbench是一款专为MySQL设计的ER/数据库建模工具.它是著名的数据库设计工具DBDesigner4的继任者.你可以用My ...
- cogs——1001. [WZOI2011 S3] 消息传递
1001. [WZOI2011 S3] 消息传递 ★★ 输入文件:messagew.in 输出文件:messagew.out 简单对比时间限制:1 s 内存限制:128 MB Prob ...
- 断路器监控(Hystrix Dashboard)
继上一篇http://www.cnblogs.com/EasonJim/p/7613595.html介绍了断路器之后,其实它还提供了一个管理页面来监控这些应用的调用数据. 首先,我是基于上一个例子Zo ...
- 制作svg动画
要实现一步一步画出来一个图片,css3做不到吧.除非一张张的图片定时显示.想不到别的招了.如今用的是一个插件,做了一个svg动画. 插件地址:http://lazylinepainter.info/ ...
- 查找olr备份路径
使用:ocrdump -local <olr_dump_name> more <olr_dump_name> 来查找 [SYSTEM.OLR.BACKUP.LOC] 的相应键值 ...
- C# 实现WEBSOCKET聊天应用示例
C# 实现WEBSOCKET聊天应用示例 http://blog.163.com/da7_1@126/blog/static/10407267820121016103055506/ 2012-11-1 ...
- [Qt总结篇]终端远程升级client
环境: QT4.8.5 for Windows(Qt Creator+MinGW) 一.写在前面: 1.深度:鉴于C/C++的功底还远远不足,个人主要精力还是学习C/C++,所以没打算继续深入研究Qt ...
- CGlib小记
CGlib是一个强大的代码生成包.常被用于各种AOP框架,提供"拦截"功能. JDK本身就为控制要訪问的对象提供了一 种途径,动态代理Proxy. 可是被代理的累必须实现一个或多个 ...
- Bootstrap button源码分析
/* ======================================================================== * Bootstrap: button.js v ...
- UVA 213 Message Decoding 【模拟】
题目链接: https://cn.vjudge.net/problem/UVA-213 https://uva.onlinejudge.org/index.php?option=com_onlinej ...