模拟 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 ...
随机推荐
- 原 linux添加虚拟ip(手动vip和keepalived方式)
https://blog.csdn.net/dear_snowing/article/details/68066544 https://www.cnblogs.com/liuyisai/p/59906 ...
- ZOJ - 3829 Known Notation(模拟+贪心)
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3829 给定一个字符串(只包含数字和星号)可以在字符串的任意位置添加一个数字 ...
- [bzoj2882]工艺_后缀数组
工艺 bzoj-2882 题目大意:题目链接. 注释:略. 想法: 跟bzoj1031差不多啊. 把串倍长后扫$sa$数组. 最后再统计答案即可. Code: #include <iostrea ...
- hibernate详解一
hibernate介绍 hibernate是一个开源的轻量级的框架, hibernate框架应用在javaee三层结构中的dao层框架,在dao层对数据库进行crud操作,使用hibernate框架实 ...
- spring boot项目自定义数据源,mybatisplus分页、逻辑删除无效解决方法
Spring Boot项目中数据源的配置可以通过两种方式实现: 1.application.yml或者application.properties配置 2.注入DataSource及SqlSessio ...
- JSP的调试
以下内容引用自http://wiki.jikexueyuan.com/project/jsp/debugging.html: 一.使用System.out.println() System.out.p ...
- ADSL和ITV
1.ADSL和ITV两者占用的是不同的虚通道,也就是使用不同的VLAN: 2.的确上通过不同的VPI/VCI来区分ADSL和ITV在不同通道,但不会互不影响的,因为使用的还是同一条线路的宽带速度: 3 ...
- 打造Spring Cloud构建微服务架构的最全资料
访问: https://git.oschina.net/didispace/SpringCloud-Learning http://blog.didispace.com/categories/Spri ...
- flask应用的分页
Flask-SQLAlchemy支持分页 https://www.jianshu.com/p/5e03cd202728
- Java之旅(1)—Class类
看到Class的时候,我们是不是会一下子想到我们敲代码中的class呢?此Class非彼class,这里讲的Class类实际上就是java类的统称,我们能够将其称之为抽象的类不是详细的一个类的名字. ...