题目链接: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. mongo创建集合

    查询 db.getCollection('tbTrade').find({strDealSN:'P2P0_153596710bb00010011ba47b342'}); 更新(第一个{}为条件) db ...

  2. 微服务SpringCloud之熔断器

    学习SpringCloud微服务是参考纯洁的微笑博客,看到他提到股市的熔断我也忍不住吐槽一下,记得当时实施熔断第一天就熔断了,现在想想也还是搞笑,从之前的全民炒股到现在的全民炒房,都是一个炒字,问题是 ...

  3. 《转载黑马教程》HTML&&CSS讲义0,,包含教程_仅供参考

    今日内容 1. web概念概述 2. HTML web概念概述 * JavaWeb: * 使用Java语言开发基于互联网的项目 * 软件架构: 1. C/S: Client/Server 客户端/服务 ...

  4. .net持续集成cake篇之cake任务依赖、自定义配置荐及环境变量读取

    系列目录 新建一个构建任务及任务依赖关系设置 上节我们通过新建一个HelloWorld示例讲解了如何编写build.cake以及如何下载build.ps1启动文件以及如何运行.实际项目中,我们使用最多 ...

  5. 基于百度EasyDL定制化图像识别平台的海洋鱼类识别方法

    [目的]鱼类识别对渔业资源的开发利用有着重要的意义.针对海底环境恶劣.拍摄环境亮度低.场景模糊的实际情况导致海底观测视频品质差,视频中的鱼类识别难的问题以及现有鱼类识别方法存在的鱼类标注数据集过少导致 ...

  6. Spring:定时任务定时器 Quartz的使用

    Quartz的使用方式 配置文件方式 一.引入依赖 <!-- spring 其他依赖省略 --> <!-- https://mvnrepository.com/artifact/or ...

  7. [剑指offer] 46. 孩子们的游戏(圆圈中最后剩下的数)

    题目描述 随机指定一个数m,让编号为0的小朋友开始报数.每次喊到m-1的那个小朋友要出列,并且不再回到圈中,从他的下一个小朋友开始,继续0...m-1报数....这样下去....直到剩下最后一个小朋友 ...

  8. SQLServer 问题(一)

    出现这种错误: [DBNETLIB][ConnectionOpen(Connect()).]SQL Server 不存在或拒绝访问 数据库错误 原因: 1.查看是不是没有在数据库中添加数据库服务器地址 ...

  9. php 常用函数总汇

    php 使用命令行函数exec($sql,$result,$status); $sql 命令   $result  返回东西  $status成功与否的状态 例如: php使用命令行去执行数据库备份( ...

  10. 使用redis分布式锁解决并发线程资源共享问题

    众所周知, 在多线程中,因为共享全局变量,会导致资源修改结果不一致,所以需要加锁来解决这个问题,保证同一时间只有一个线程对资源进行操作 但是在分布式架构中,我们的服务可能会有n个实例,但线程锁只对同一 ...