【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 ...
随机推荐
- C++中一个函数隐藏的有趣例子
函数隐藏是一个函数的定义或声明导致其他一些函数不可见. 函数A隐藏函数B的条件: 1. 两个函数具有相同的函数名称 2. 具有不同的作用域.所谓定义域函数定义或声明的位置,如全局作 ...
- C primer plus 读书笔记第十章
这一章的标题是数组和指针.指针是C语言的精髓所在,而数组的概念和指针又息息相关,所以放在一起讲. 1.数组 主要内容有:1.1.数组初始化.1.2.指定初始化.1.3.数组赋值.1.4.数组边界.1. ...
- [Angular 2] Passing data to components with 'properties'
Besides @Input(), we can also use properties on the @Component, to pass the data. import {Component, ...
- CSU1661: Query Mutiple
Description One day,Little-Y saw many numbers standing in a row. A question suddenly appeared in her ...
- mac下使用brew安装svn javahl的问题
eclipse老提示javahl太久必须得1.8以上,以前不知道什么时候在/usr/bin装过1.7的svn. 1. 删除1.7的svn sudo rm /usr/bin/svn 2.使用brew安装 ...
- 7-http1.1和2.0的区别?
1.多路复用:减少tcp请求 合并成一个2.首部压缩:会把多个首部压缩3.服务器推送:不用request也可以response
- 登录模块需要用到session留底
<% HttpSession sessions=request.getSession(); Object sessionValues=sessions.getAttribute("ui ...
- Java POI 两种导出方式
这里面包含了模板导出方法和自定义模板进行导出 package jp.co.syspro.poo.action.hibikoyou; import java.io.ByteArrayOutputStre ...
- Pgsql 里面 COALESCE的用法
有这种要求,更新自己本身的字段的某个值进行加或者减, 常规方法: UPDATE tbl_kintai_print_his SET print_time = now(), print_emp_cd = ...
- (转)PHP的ereg()与eregi()的不同及相同点。对比
ereg() 字符串比对解析. 语法: int ereg(string pattern, string string, array [regs]); 返回值: 整数/数组 函数种类: 资料处理 内容说 ...