【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 ...
随机推荐
- Windows7下32位IE异常不能打开解决方法
今天更新了Update及安装了一些软件,重启电脑后发现32位IE不能正常打开,而64位IE正常. 错误信息如下: 问题签名: 问题事件名称: BEX 应用程序名: iexplore.exe 应用 ...
- 【动态页面】(二)Java反射
Java的反射机制是Java语言非常重要的一个特性.先从Sun官网上看一下官网是怎样定义反射机制的. 大致翻译一下,翻译的可能不是非常准确. 反射(Reflection)是Java程序设计语言的一个特 ...
- [转] 怎样快速而优雅地遍历 JavaScript 数组
我们一般用循环来遍历数组,而循环一直是 JavaScript 性能问题的常见来源,有时循环用得不好会严重降低代码的运行速度.例如,遍历数组时,我们会很自然地写出下面这种代码: // 未优化的代码1 v ...
- [转] Javascript中数组与字典(即object)的使用
简述: 简单记录一下数据结构字典和数组, 其实在Javascript这种弱类型的脚本语言中,数组同时也就是字典,下面主要就是字典数组的简易使用 代码: 1. 数组中添加map <!DOCTYPE ...
- C#泛型类的简单创建与使用
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Cons ...
- vsftp配置主动模式和被动模式
配置文件:/etc/vsftpd/vsftpd.conf 主动模式配置方法: 主动式连接使用的数据通道 connect_from_port_20=YES 支持数据流的被动式连接模式 pasv_enab ...
- java.util 中的property
学习中 两个博客: http://swiftlet.net/archives/1023 http://www.cnblogs.com/lingiu/p/3468464.html
- 大牛对ACM入门菜鸟的一些话
首先就是我为什么要写这么一篇日志.原因很简单,就是因为前几天有个想起步做ACM人很诚恳的问我该如何入门.其实就现在而言,我并不是很想和人再去讨论这样的话题,特别是当我发现我有很多的东西要学的时候,我实 ...
- AmazeUI 模态框封装
/** * 模态窗口 */ window.Modal = { tpls:{ alert:'<div class="am-modal am-modal-alert" tabin ...
- HTML5 离线缓存忽略主页实例
默认情况下 指定html mianfest的当前页面会自动离线缓存到客户端. 取消的方法,可以使用iframe类实现 1.主页定义: <iframe frameborder="no&q ...