简单模拟,题目数据太弱太弱了。

 /* 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 武林的更多相关文章

  1. 武林 HDU - 1107

    题目链接:https://vjudge.net/problem/HDU-1107 注意:题目中只有两个不同门派的人在同一个地方才能对决,其他情况都不能对决. 还有,这步的有效的攻击只有走到下一步之后才 ...

  2. HDOJ 1009. Fat Mouse' Trade 贪心 结构体排序

    FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  3. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  4. HDOJ 1326. Box of Bricks 纯水题

    Box of Bricks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  5. ACM: NBUT 1107 盒子游戏 - 简单博弈

     NBUT 1107  盒子游戏 Time Limit:1000MS     Memory Limit:65535KB     64bit IO Format:  Practice  Appoint ...

  6. HDOJ 1004 Let the Balloon Rise

    Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...

  7. hdoj 1385Minimum Transport Cost

    卧槽....最近刷的cf上有最短路,本来想拿这题复习一下.... 题意就是在输出最短路的情况下,经过每个节点会增加税收,另外要字典序输出,注意a到b和b到a的权值不同 然后就是处理字典序的问题,当松弛 ...

  8. HDOJ(2056)&HDOJ(1086)

    Rectangles    HDOJ(2056) http://acm.hdu.edu.cn/showproblem.php?pid=2056 题目描述:给2条线段,分别构成2个矩形,求2个矩形相交面 ...

  9. 继续node爬虫 — 百行代码自制自动AC机器人日解千题攻占HDOJ

    前言 不说话,先猛戳 Ranklist 看我排名. 这是用 node 自动刷题大概半天的 "战绩",本文就来为大家简单讲解下如何用 node 做一个 "自动AC机&quo ...

随机推荐

  1. [转] linux下的c/c++调试器gdb

    PS:1. 断点C++类函数,用b 命名空间::类名::方法名 2. 编译参数一定要加-g,才可断点调试 http://www.cnblogs.com/xd502djj/archive/2012/08 ...

  2. android之旅——开始

    1.文件的读取 io流读取文件,并且显示 package com.helloword; import java.io.BufferedReader; import java.io.File; impo ...

  3. ubuntu wine卸载程序并删除图标

    卸载ubuntu 下用wine安装的程序,可以用wine uninstaller命令,打开 添加/删除程序界面,进行删除程序操作:

  4. Android 连接 SQL Server (jtds方式)——下

    本文主要补充介绍jtds的查询方法,将以博主的一个实际开发程序进行说明 下图是项目的文件列表与界面效果:          运行效果: 1.三个EditText对应的是单个计划的序号.品种名.数量 2 ...

  5. Android 中Webview 自适应屏幕

    随笔 - 478  文章 - 3  评论 - 113 Android 中Webview 自适应屏幕   webview中右下角的缩放按钮能不能去掉 settings.setDisplayZoomCon ...

  6. C#中的IO流操作(FileStream)

    StreamReader和StreamWriter适用于对文本文件的操作,因为它是以字符为单位进行的操作 不用担心编码问题 using (Stream s = new FileStream(@&quo ...

  7. xls和xlsx

      xls XLS 就是 Microsoft Excel 工作表,是一种非常常用的电子表格格式.xls文件可以使用Microsoft Excel打开,另外微软为那些没有安装Excel的用户开发了专门的 ...

  8. updatepanel的属性

    updatepanel的属性 1.childrenastriggers:内容模板内的子控件的回发是否更新本模板(和updatemode的conditional有关) 2.updatemode:内容模板 ...

  9. javascript基础学习(十三)

    javascript之文档对象 学习要点: 文档对象 文档对象的应用 一.文档对象 Document对象是代表一个浏览器窗口或框架中的显示HTML文件的对象.javascript会为每个HTML文档自 ...

  10. 一起学makefile

    Unix.Linux必学知识哈哈,网上看到一哥们写得挺好挺详细的,直接复制地址就分享哈哈哈. 跟我一起写 Makefile(一) 概述 跟我一起写 Makefile(二) make是如何工作的 跟我一 ...