武林 HDU - 1107
题目链接: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的更多相关文章
- 【HDOJ】1107 武林
简单模拟,题目数据太弱太弱了. /* 1107 */ #include <iostream> #include <cstdio> #include <cstring> ...
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
- [转] HDU 题目分类
转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...
- HDU ACM 题目分类
模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...
- HDU 2502 月之数(二进制,规律)
月之数 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submis ...
- HDU 5643 King's Game 打表
King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...
- hdu 1174:爆头(计算几何,三维叉积求点到线的距离)
爆头 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...
- 转载:hdu 题目分类 (侵删)
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...
- HDU 1410 PK武林盟主
Problem Description 枫之羽认为自己很强,想当武林盟主,于是找现任武林盟主氢氧化铜挑战.氢氧化铜欣然接受了挑战,两人约好于下个月的月圆之夜在HDU校园内的三根柱子上进行决战.这场PK ...
随机推荐
- hive 之 Cube, Rollup介绍
1. GROUPING SETS GROUPING SETS作为GROUP BY的子句,允许开发人员在GROUP BY语句后面指定多个统维度,可以简单理解为多条group by语句通过union al ...
- 蓝桥杯:最大的算式(爆搜 || DP)
http://lx.lanqiao.cn/problem.page?gpid=T294 题意:中文题意. 思路:1.一开始想的是,乘号就相当于隔板,把隔板插入到序列当中,同一个隔板的就是使用加法运算, ...
- 利用iisnode模块,让你的Node.js应用跑在Windows系统IIS中
最近比较喜欢用Node.js做一些简单的应用,一直想要部署到生产环境中,但是手上只有一台windows server 2008服务器,并且已经开启了IIS服务,运行了很多.Net开发的网站,80端口已 ...
- Object.keys使用整理
一.语法 Object.keys(obj) 参数:要返回其枚举自身属性的对象 返回值:一个表示给定对象的所有可枚举属性的字符串数组 二.处理对象,返回可枚举的属性数组 let person = { n ...
- markdown的博客
测试一下markdown写博客 function firstProgram() { console.log("This is my first markdown blog"); }
- ES6中的解构
数组中的解构: 输出 : 白板 幺鸡 二条 对象的解构: 输出: 老王 12 数组的结构用[];对象的解构用{}:一定要区分它是数组还是解构. 区分方法:看 它是在赋值还是在拿值,等号左边,都为解构, ...
- LaTeX大全
1.指数和下标可以用^和_后加相应字符来实现.比如: 2.平方根(square root)的输入命令为:\sqrt,n 次方根相应地为: \sqrt[n].方根符号的大小由LATEX自动加以调整.也可 ...
- 个人永久性免费-Excel催化剂功能第44波-可见区域复制粘贴不覆盖隐藏内容
Excel的复制粘贴操作,每天都在进行,若其中稍能提升一点效率,长久来说,实在是很可观的效率提升. Excel自带的复制粘贴功能,若复制的数据源或粘贴的目标位置中有隐藏的行列内容,简单一个复制粘贴充满 ...
- 题解 P1864 【[NOI2009]二叉查找树】
#include<cstdio> #include<string> #include<cstring> #include<iostream> #incl ...
- SpringBoot学习笔记3
十六:自定义拦截器 参考文档 16.1 编写拦截器类 extends WebMvcConfigurerAdapter 并重写WebMvcConfigurerAdapter,如下: package co ...