简单模拟,题目数据太弱太弱了。
/* 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 ;
}