【HDOJ】1107 武林
简单模拟,题目数据太弱太弱了。
/* 1107 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std; typedef struct node_t {
int x, y; // position
int nl; // 内力
int wy; // 武艺
int hp; // 生命
bool hasFight;
int d; // direction: 0:up, down:1
node_t() {}
node_t(int xx, int yy, int nnl, int wwy, int hhp, bool h=false, int dd=) {
x = xx; y = yy; nl = nnl; wy = wwy;
hp = hhp; hasFight=h; d = dd;
}
} node_t; int map[][];
vector<node_t> vnodes[]; // 0:少林, 1:武当, 2:峨眉
int dir[][][] = {
{ {, }, {-, } },
{ {, }, {-, } },
{ {, }, {-, -} }
};
int nn[];
int t, n; void init() {
memset(map, , sizeof(map));
for (int i=; i<; ++i) {
vnodes[i].clear();
nn[i] = ;
}
} inline bool check(int x, int y) {
return x> && x< && y> && y<;
} int getDPS(int i, int j) {
double tmp; if (i == ) {
tmp = (0.5*vnodes[i][j].nl + 0.5*vnodes[i][j].wy) * (vnodes[i][j].hp + .) / 100.0;
} else if (i == ) {
tmp = (0.8*vnodes[i][j].nl + 0.2*vnodes[i][j].wy) * (vnodes[i][j].hp + .) / 100.0;
} else {
tmp = (0.2*vnodes[i][j].nl + 0.8*vnodes[i][j].wy) * (vnodes[i][j].hp + .) / 100.0;
} return (int) tmp;
} void fight() {
int dps0, dps1;
int i, j, k, p;
int ii, jj, kk;
int x, y; for (i=; i<; ++i) {
for (j=; j<nn[i]; ++j) {
if (vnodes[i][j].hp> && map[vnodes[i][j].x][vnodes[i][j].y]== && !vnodes[i][j].hasFight) {
x = vnodes[i][j].x;
y = vnodes[i][j].y;
vnodes[i][j].hasFight = true;
for (ii=; ii<; ++ii) {
if (ii == i)
continue;
for (jj=; jj<nn[ii]; ++jj) {
if (vnodes[ii][jj].hp> && vnodes[ii][jj].x==x && vnodes[ii][jj].y==y) {
dps0 = getDPS(i, j);
dps1 = getDPS(ii, jj);
vnodes[i][j].hp -= dps1;
vnodes[ii][jj].hp -= dps0;
vnodes[ii][jj].hasFight = true;
}
}
}
}
}
}
} void move() {
int i, j, k;
int x, y, xx, yy; for (i=; i<; ++i) {
for (j=; j<nn[i]; ++j) {
vnodes[i][j].hasFight = false;
x = vnodes[i][j].x;
y = vnodes[i][j].y;
--map[x][y];
k = vnodes[i][j].d;
if (i == ) {
if (x == ) k = ;
if (x == ) k = ;
if (k) {
--x;
} else {
++x;
}
} else if (i == ) {
if (y == ) k = ;
if (y == ) k = ;
if (k) {
--y;
} else {
++y;
}
} else {
if (x== || y==)
k = ;
if (x== || y==)
k = ;
if ((x==&&y==) || (x== && y==))
/* do nothing */;
else {
if (k) {
--x; --y;
} else {
++x; ++y;
}
}
}
vnodes[i][j].d = k;
vnodes[i][j].x = x;
vnodes[i][j].y = y;
++map[x][y];
}
}
} int main() {
int i, j, k, tmp;
int x, y, nl, wy, hp;
char cmd[]; #ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif scanf("%d", &t);
while (t--) {
init();
scanf("%d", &n);
while (scanf("%s", cmd)!=EOF && (cmd[]!='')) {
scanf("%d %d %d %d %d", &x, &y, &nl, &wy, &hp);
if (cmd[] == 'S') j = ;
if (cmd[] == 'W') j = ;
if (cmd[] == 'E') j = ;
++map[x][y];
vnodes[j].push_back(node_t(x,y,nl,wy,hp));
++nn[j];
}
while (n--) {
fight();
move();
}
for (i=; i<; ++i) {
k = ;
n = ;
for (j=; j<nn[i]; ++j) {
if (vnodes[i][j].hp > ) {
k += vnodes[i][j].hp;
++n;
}
}
printf("%d %d\n", n, k);
}
puts("***");
} return ;
}
【HDOJ】1107 武林的更多相关文章
- 武林 HDU - 1107
题目链接:https://vjudge.net/problem/HDU-1107 注意:题目中只有两个不同门派的人在同一个地方才能对决,其他情况都不能对决. 还有,这步的有效的攻击只有走到下一步之后才 ...
- HDOJ 1009. Fat Mouse' Trade 贪心 结构体排序
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- HDOJ 1326. Box of Bricks 纯水题
Box of Bricks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- ACM: NBUT 1107 盒子游戏 - 简单博弈
NBUT 1107 盒子游戏 Time Limit:1000MS Memory Limit:65535KB 64bit IO Format: Practice Appoint ...
- HDOJ 1004 Let the Balloon Rise
Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...
- hdoj 1385Minimum Transport Cost
卧槽....最近刷的cf上有最短路,本来想拿这题复习一下.... 题意就是在输出最短路的情况下,经过每个节点会增加税收,另外要字典序输出,注意a到b和b到a的权值不同 然后就是处理字典序的问题,当松弛 ...
- HDOJ(2056)&HDOJ(1086)
Rectangles HDOJ(2056) http://acm.hdu.edu.cn/showproblem.php?pid=2056 题目描述:给2条线段,分别构成2个矩形,求2个矩形相交面 ...
- 继续node爬虫 — 百行代码自制自动AC机器人日解千题攻占HDOJ
前言 不说话,先猛戳 Ranklist 看我排名. 这是用 node 自动刷题大概半天的 "战绩",本文就来为大家简单讲解下如何用 node 做一个 "自动AC机&quo ...
随机推荐
- php导出excel不断刷新缓冲区的思路(转)
require('./db.class.php');$DB = new db();$DB->connect();//数据库链接 header("Content-Type: text/c ...
- 动态用javascript来修改单选框性别
<script> window.onload=function(){ if(<{$data.sex}>==0){//<{$data.sex}>是在数据读出来: do ...
- HDU 2476 String painter(区间dp)
题意: 给定两个字符串,让求最少的变化次数从第一个串变到第二个串 思路: 区间dp, 直接考虑两个串的话太困难,就只考虑第二个串,求从空白串变到第二个串的最小次数,dp[i][j] 表示i->j ...
- 国内优秀npm镜像
淘宝npm镜像 淘宝npm镜像:http://npm.taobao.org/ 1.临时使用 npm --registry https://registry.npm.taobao.org install ...
- jsp引入struts标签,引入自己写的jquery需要注意的问题
1.使用struts2标签的时候在jsp页面开头引入这句话: <%@ taglib prefix="s" uri="/struts-tags"%> ...
- Oracle NULLIF函数
Oracle NULLIF函数 Oracle NULLIF函数语法为NULLIF(表达式1,表达式2),如果表达式1和表达式2相等则返回空值,如果表达式1和表达式2不相等则返回表达式1的结果. 注意: ...
- AFNetworking使用详解
导语: 众所周知,AFNetworking是目前IOS开发中非常受欢迎的第三方网络通信类库,同时AFNetworking对苹果官方NSURLConnection和NSURLSession进行了封装,使 ...
- 浅谈C++ Lambda 表达式(简称LB)
C++ 11 对LB的支持,对于喜欢Functional Programming的人来说,无疑是超好消息.它使得C++进入了和C#,JavaScript等现代流行的程序设计语言所代表的名人堂. 不熟悉 ...
- 安装SVN及实现nginx web同步更新需要在WDCP一键安装包的基础上
一.安装 1.查看是否安装cvs rpm -qa | grep subversion 2.安装 yum install subversion 3.测试是否安装成功 /usr/bin/svnserve ...
- java使用json抛出org.apache.commons.lang.exception.NestableRuntimeException解决方案
出现这个问题,说明缺少jar包,将下面的jar引入即可 commons-beanutils-1.8.3 commons-lang-2.6 (注:导入最新的 3.1 版本会继续报如下错误) common ...