题目链接:https://vjudge.net/problem/HDU-1107

注意:题目中只有两个不同门派的人在同一个地方才能对决,其他情况都不能对决。

还有,这步的有效的攻击只有走到下一步之后才生效,所以会出现样例1和样例2的情况。

代码有注释,便于理解,这理我说一下vis[][][]数组的用处。

vis[x][x][1] 表示少林寺人的编号。

vis[x][x][2] 表示武当派人的编号。

vis[x][x][3] 表示峨眉派人的编号。

vis[x][x][4] 表示一个门派是否有超过两个人。


 #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std; typedef long long LL;
#define inf (1LL << 25)
#define rep(i,j,k) for(int i = (j); i <= (k); i++)
#define rep__(i,j,k) for(int i = (j); i < (k); i++)
#define per(i,j,k) for(int i = (j); i >= (k); i--)
#define per__(i,j,k) for(int i = (j); i > (k); i--) const int N = ;
int vis[N][N][];
int steps; struct People{ char c; //门派
int tot;//标记
int x,y;//坐标
int dir;//方向 正负1来方便判断
int nx,wx,sx; int att(){//攻击
if(c == 'S') return (0.5 * nx + 0.5 * wx) * (sx * 1.0 + ) /;
else if(c == 'W') return (0.8 * nx + 0.2 * wx) * (sx * 1.0 + ) /;
else if(c == 'E') return (0.2 * nx + 0.8 * wx) * (sx * 1.0 + ) /;
} //被攻击
void is_att(int x) { sx -= x;} //移动
void mv(){
if(c == 'S'){
if(!(x + dir >= && x + dir <= )) dir = -dir;
x += dir;
}
else if(c == 'W'){
if(!(y + dir >= && y + dir <= )) dir = -dir;
y += dir;
}
else if(c == 'E'){
int xx = x + dir;
int yy = y + dir;
if(!(xx >= && xx <= && yy >= && yy <= )) dir = -dir;
if(x + dir >= && x + dir <= && y + dir >= && y + dir <= ) x += dir, y += dir;
}
} //写下标记
void vis_w(){
if(c == 'S'){
if(vis[x][y][] == ) vis[x][y][] = tot;
else vis[x][y][] = ;
}
else if(c == 'W'){
if(vis[x][y][] == ) vis[x][y][] = tot;
else vis[x][y][] = ; }
else if(c == 'E'){
if(vis[x][y][] == ) vis[x][y][] = tot;
else vis[x][y][] = ;
}
} //擦除标记
void vis_e(){
rep(i,,) vis[x][y][i] = ;
} }p[];
bool died[]; //该编号的人是否死亡
int pl;//人数 void work(){ rep(q,,steps){
rep(i,,) rep(j,,){ if(vis[i][j][] == ) continue; //一个门派超过两个人
int a = ,b = ,num = ;
rep(p,,) if(vis[i][j][p] != ){
num++;
if(!a) a = vis[i][j][p];
else b = vis[i][j][p];
} if(num != ) continue; //不是两个人 int w1 = p[a].att();
int w2 = p[b].att();
p[a].is_att(w2);
p[b].is_att(w1);
} rep(o,,pl) if(!died[o]){
p[o].vis_e();//擦除标记
if(p[o].sx <= ) died[o] = true;
} rep(o,,pl) if(!died[o]){
p[o].mv();
p[o].vis_w();//标记
}
}
} void print(){ int m[] = {};
int t[] = {}; rep(o,,pl){
if(died[o]) continue; if(p[o].c == 'S') m[]++, t[] += p[o].sx;
else if(p[o].c == 'W') m[]++, t[] += p[o].sx;
else if(p[o].c == 'E') m[]++, t[] += p[o].sx;
} cout << m[] << ' ' << t[] << endl;
cout << m[] << ' ' << t[] << endl;
cout << m[] << ' ' << t[] << endl;
cout << "***" << endl;
} int main(){ ios::sync_with_stdio(false);
cin.tie(); int T;
cin >> T;
char in;
while(T--){ pl = ;
rep(i,,) died[i] = false;
rep(i,,) rep(j,,) rep(k,,) vis[i][j][k] = ;
cin >> steps; while(cin >> in){
if(in == ''){
break;
} ++pl;
p[pl].c = in;
p[pl].tot = pl;
p[pl].dir = ;
cin >> p[pl].x >> p[pl].y >> p[pl].nx >> p[pl].wx >> p[pl].sx;
p[pl].vis_w();
}
work();
print();
} getchar(); getchar();
return ;
}

武林 HDU - 1107的更多相关文章

  1. 【HDOJ】1107 武林

    简单模拟,题目数据太弱太弱了. /* 1107 */ #include <iostream> #include <cstdio> #include <cstring> ...

  2. HDU——PKU题目分类

    HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...

  3. [转] HDU 题目分类

    转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...

  4. HDU ACM 题目分类

    模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...

  5. HDU 2502 月之数(二进制,规律)

    月之数 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submis ...

  6. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  7. hdu 1174:爆头(计算几何,三维叉积求点到线的距离)

    爆头 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...

  8. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

  9. HDU 1410 PK武林盟主

    Problem Description 枫之羽认为自己很强,想当武林盟主,于是找现任武林盟主氢氧化铜挑战.氢氧化铜欣然接受了挑战,两人约好于下个月的月圆之夜在HDU校园内的三根柱子上进行决战.这场PK ...

随机推荐

  1. HDU 4819:Mosaic(线段树套线段树)

    http://acm.hdu.edu.cn/showproblem.php?pid=4819 题意:给出一个矩阵,然后q个询问,每个询问有a,b,c,代表(a,b)这个点上下左右c/2的矩形区域内的( ...

  2. ORACLE导入数据库详细步骤

    登录PLSQL 点击然后打开命令窗口执行命令 创建表空间(红色字体是你需要创建表空间的地址,蓝色的是表空间大小) create temporary tablespace ZJY_TEMP tempfi ...

  3. Linux中修改远程地址

    首先跳转到本地用户root,如果不是的话可能没有权限 第一步:安装ssh服务 执行命令:yum install openssh-server (因为我已经安装过了,所以显示的是已安装) 第二步:修改S ...

  4. redis源码笔记-内存管理zmalloc.c

    redis的内存分配主要就是对malloc和free进行了一层简单的封装.具体的实现在zmalloc.h和zmalloc.c中.本文将对redis的内存管理相关几个比较重要的函数做逐一的介绍 参考: ...

  5. C#常用正则表达式回顾

    项目中有些时候需要用到正则表达式,但是自己对正则表达式不熟悉,每次学习完,过一段时间(长时间)不用,就又忘了,每次需要用到的时候都需要百度下,比较麻烦,这里把C#中经常用到的正则表达式做下总结. 正则 ...

  6. Noip 2016 愤怒的小鸟 题解

    [NOIP2016]愤怒的小鸟 时间限制:1 s   内存限制:256 MB [题目描述] Kiana最近沉迷于一款神奇的游戏无法自拔. 简单来说,这款游戏是在一个平面上进行的. 有一架弹弓位于(0, ...

  7. css基础4

    今天是2019年6月21日,周五了.在这里写上一篇随笔,主要内容是css基础中的一些细节部分,话不多说,直接上! 一.背景渐变: background-image 线性渐变:linear-gradie ...

  8. String 的成员函数

    本篇是把一些string的成员函数的用法记录下来 size()函数和lenth()函数 s.size()或者s.lenth() 它们都会返回长度,是总长度而不是下标长度 find函数 s.find(s ...

  9. 《深入理解 Java 内存模型》读书笔记

    ![img](https://mmbiz.qpic.cn/mmbiz_jpg/1flHOHZw6RtPu3BNx3zps1JhSmPICRw7QgeOmxOfTbCT3RLgIo4qRpn6xL4qg ...

  10. 安卓开发之详解getChildFragmentManager和getsupportFragmentManager和getFragmentManager详解

    安卓开发之详解getChildFragmentManager和getsupportFragmentManager和getFragmentManager详解 getFragmentManager()所得 ...