武林 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 ...
随机推荐
- leetcode的Hot100系列--136. 只出现一次的数字
因为之前刚写了461号题目,这个题目与那个很相似, 461号题目用异或来算两个不一样的部分, 那这个题目需要排除一样的部分,并找到不一样的部分. 那么可以再利用一下异或的特性: 1.相同为0,所以,a ...
- Weblogic 'wls-wsat' XMLDecoder 反序列化_CVE-2017-10271漏洞复现
Weblogic 'wls-wsat' XMLDecoder 反序列化_CVE-2017-10271漏洞复现 一.漏洞概述 WebLogic的 WLS Security组件对外提供webservic ...
- js 为何范围内随机取整要用floor,而不是ceil或者round呢
壹 ❀ 引 我在如何使用js取任意范围内随机整数这篇博客中,列举并分析了取[n,m)与[n,m]范围内整数的通用方法,并在文章结果留了一个疑问:为什么通用方法中取整操作,我们使用Math.floor ...
- Spring 核心技术(2)
接上篇:Spring 核心技术(1) version 5.1.8.RELEASE 1.3 Bean概述 Spring IoC 容器管理一个或多个bean,他们都是根据提供的配置元数据(例如 XML 中 ...
- Spring boot ,dubbo整合异常
Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException: com.guooo.boot.acc.serv ...
- Java设计模式学习笔记(三) 工厂方法模式
前言 本篇是设计模式学习笔记的其中一篇文章,如对其他模式有兴趣,可从该地址查找设计模式学习笔记汇总地址 1. 简介 上一篇博客介绍了简单工厂模式,简单工厂模式存在一个很严重的问题: 就是当系统需要引入 ...
- 预学第二天:计算机的基础知识+python安装+pycharm安装+思维导图
目录 计算机的基础知识 计算机是由什么组成的 什么是操作系统
- Java编程思想:内存映射文件
import java.io.*; import java.nio.IntBuffer; import java.nio.MappedByteBuffer; import java.nio.chann ...
- [原创]SSH Tunnel for UDP
SSH Tunnel for UDP UDP port forwarding is a bit more complicated. We will need to convert the packet ...
- 获取文件版本(IE)
GetFileInfoCUIAction::GetFileVersion2GetSystemDirectory WCHAR szConfigFile[MAX_PATH + 1]; ::G ...