Luogu2586 [ZJOI2008]杀蚂蚁

题意

还是一道大模拟

https://www.luogu.org/problemnew/show/P2586

大概就是炮塔大蚂蚁的故事

下载这个游戏http://www.antbuster.net/Antbuster_12k_20090824.swf

还是比较难玩的

题解

就是预处理塔能打到的位置,然后直接把一局游戏分成几个阶段,同时每个阶段做了什么事也比较清楚,然后思路就比较清晰

一些经验:

  1. 尽量预处理一些静态的东西,然后不要临时算,这样会把整个函数弄得比较杂乱
  2. 容器什么的其实在Linux内是可以直接查看的,但是依然推荐通过运行输出查看,因为这样有一个跟踪容器变化的效果
  3. 每次更改代码之后记录一下改了什么地方,或者是版本控制
  4. 逻辑错误GDB不可行
  5. 然后这次精简了一些函数,可能对于整体效果来说还是比较可以的
 //Created By Creeper_LKF
//Caution::We used "pragma" in the code
#include <cstdio>
#include <cctype>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream> #ifdef __gnu_linux__ #include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h> #endif #if __cplusplus < 201103L #include <stdarg.h> #endif //Algorithm Heads #include <list>
#include <cmath>
#include <queue>
#include <utility>
#include <algorithm> using namespace std; //FILE_NAME DEFINATION //Debug Port #define DEBUG_PORT
#define DEBUG 1 #ifdef ONLINE_JUDGE
#undef DEBUG_PORT
#endif #ifdef DEBUG_PORT
#if __cplusplus < 201103L
# pragma message "Warning : C++11 Not Use"
#ifdef DEBUG
template<typename T>
extern inline void Debug(T tar){
cerr << tar << endl;
}
template<typename Head, typename T, typename... Tail>
extern inline void Debug(Head head, T mid, Tail... tail){
cerr << head << ' ';
Debug(mid, tail...);
}
#else
template<typename Head, typename T, typename... Tail>
extern inline void Debug(Head head, T mid, Tail... tail){
return ;
}
#endif
#else
#ifdef DEBUG
template <typename T>
extern inline void Debug(T tar){
cerr << tar << endl;
}
#else
template <typename T>
extern inline void Debug(T tar){
return ;
}
#endif
#endif
#else
template <typename T>
extern inline void Debug(T tar){
return ;
}
#endif const char file_name[] = "b"; #define NAME_SPACE
#define USING #ifdef NAME_SPACE
namespace LKF{
#endif
#define SF_READ
#define EOF_READ
// #define ONLINE_JUDGE
#define WRITE_ENDL
// #define FAST_WRITE
#define SPLIT_WRITE
const size_t MAX_BUF_SIZE = ; #define NEED_FILE #ifdef FAST_WRITE
char outp[MAX_BUF_SIZE], *op = outp;
#endif #ifdef ONLINE_JUDGE
#undef NEED_FILE
#endif #ifdef FAST_WRITE
#ifndef WRITE_ENDL
#define WRITE_ENDL
#endif
#endif extern inline void FILE_OPT(){
#ifdef NEED_FILE
#define FILE_NAME file_name
char IN_FILE[sizeof(FILE_NAME) + ], OUT_FILE[sizeof(FILE_NAME) + ];
strcpy(IN_FILE, FILE_NAME), strcpy(OUT_FILE, FILE_NAME);
strcat(IN_FILE, ".in"), strcat(OUT_FILE, ".out");
freopen(IN_FILE, "r", stdin);
freopen(OUT_FILE, "w", stdout);
#endif
} #ifdef __gnu_linux__ char *pc; extern inline void Main_Init(){
static bool INITED = false;
if(INITED){
#ifdef FAST_WRITE
fwrite(outp, , op - outp - , stdout);
#endif
fclose(stdin), fclose(stdout);
} else {
FILE_OPT();
pc = (char *) mmap(NULL, lseek(, , SEEK_END), PROT_READ, MAP_PRIVATE, , );
INITED = true;
}
} #else char buf[MAX_BUF_SIZE], *pc = buf; extern inline void Main_Init(){
static bool INITED = false;
if(INITED){
#ifdef FAST_WRITE
fwrite(outp, , op - outp - , stdout);
#endif
fclose(stdin), fclose(stdout);
} else {
FILE_OPT();
fread(buf, , MAX_BUF_SIZE, stdin);
INITED = true;
}
} #endif inline char read_ch(){
char c;
while(isspace(c = *pc ++));
return c;
} #ifdef EOF_READ #ifdef SF_READ template<typename T>
static inline void read(T &num){
num = ;
char c, sf = ;
while(isspace(c = *pc++));
if(c == ) sf = -, c = *pc ++;
while(num = num * + c - , isdigit(c = *pc++));
num *= sf;
} static inline int read(){
int num = ;
char c, sf = ;
while(isspace(c = *pc++));
if(c == ) sf = -, c = *pc ++;
while(num = num * + c - , isdigit(c = *pc++));
return num * sf;
} static inline double read_dec(){
double num = , decs = ;
char c, sf = ;
while(isspace(c = *pc ++));
if(c == '-') sf = -, c = *pc ++;
while(num = num * + c - , isdigit(c = *pc ++));
if(c != '.') return num * sf;
c = *pc ++;
while(num += (decs *= 0.1) * (c - ), isdigit(c = *pc ++));
return num * sf;
} #else template<typename T>
static inline T read(T &num){
num = ;
char c;
while (isspace(c = *pc++));
while (num = num * + c - , isdigit(c = *pc++));
return num;
} static inline int read(){
int num = ;
char c;
while (isspace(c = *pc++));
while (num = num * + c - , isdigit(c = *pc++));
return num;
} static inline double read_dec(){
double num = , decs = ;
char c;
while(isspace(c = *pc ++));
while(num = num * + c - , isdigit(c = *pc ++));
if(c != '.') return num;
c = *pc ++;
while(num += (c - ) * (decs *= 0.1), isdigit(c = *pc ++));
return num;
} #endif #else #ifdef SF_READ template<typename T>
static inline void read(T &num){
num = ;
char c, sf = ;
while((c = *pc++) < );
if(c == ) sf = -, c = *pc ++;
while(num = num * + c - , (c = *pc++) >= );
num *= sf;
} static inline int read(){
int num = ;
char c, sf = ;
while((c = *pc++) < );
if(c == ) sf = -, c = *pc ++;
while(num = num * + c - , (c = *pc++) >= );
return num * sf;
} static inline double read_dec(){
double num = , decs = ;
char c, sf = ;
while(isspace(c = *pc ++));
if(c == '-') sf = -, c = *pc ++;
while(num = num * + c - , isdigit(c = *pc ++));
if(c != '.') return num * sf;
c = *pc ++;
while(num += (decs *= 0.1) * (c - ), isdigit(c = *pc ++));
return num * sf;
} #else template<typename T>
static inline T read(T &num){
num = ;
char c;
while ((c = *pc++) < );
while (num = num * + c - , (c = *pc++) >= );
return num;
} static inline int read(){
int num = ;
char c;
while ((c = *pc++) < );
while (num = num * + c - , (c = *pc++) >= );
return num;
} static inline double read_dec(){
double num = , decs = ;
char c;
while(isspace(c = *pc ++));
while(num = num * + c - , isdigit(c = *pc ++));
if(c != '.') return num;
c = *pc ++;
while(num += (c - ) * (decs *= 0.1), isdigit(c = *pc ++));
return num;
} #endif #endif #ifdef FAST_WRITE
template <typename T>
inline void Call_Write(char Split, T tar){
char buf[];
int top = ;
if(tar == ) *op ++ = ;
else {
if(tar < ) *op ++ = '-', tar = -tar;
while(tar) buf[++top] = tar % , tar /= ;
while(top) *op ++ = buf[top --] ^ ;
}
*op ++ = Split;
}
template <typename T>
inline void Call_Write(T tar){
char buf[];
int top = ;
if(tar == ) *op ++ = ;
else {
if(tar < ) *op ++ = '-', tar = -tar;
while(tar) buf[++top] = tar % , tar /= ;
while(top) *op ++ = buf[top --] ^ ;
}
}
#endif #ifdef FAST_WRITE extern inline void write(){
*op ++ = '\n';
} template<typename T>
extern inline void write(T tar){
Call_Write(tar);
#ifdef WRITE_ENDL
write();
#endif
} #if __cplusplus >= 201103L # pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunused-parameter" template<typename T>
extern inline void write(char Split, T tar){
Call_Write(tar);
#ifdef WRITE_ENDL
write();
#endif
} # pragma GCC diagnostic pop
# pragma message "Warning : pragma used" template<typename Head, typename T, typename... Tail>
extern inline void write(char Split, Head head, T mid, Tail... tail){
Call_Write(Split, head);
write(Split, mid, tail...);
} #else template <typename T>
extern inline void write(char Split, T tar){
Call_Write(tar);
#ifdef WRITE_ENDL
write();
#endif
} #endif #else extern inline void write(){
cout << endl;
} template<typename T>
extern inline void write(T tar){
cout << tar;
#ifdef WRITE_ENDL
write();
#endif
} #if __cplusplus >= 201103L template<typename T>
extern inline void write(char Split, T tar){
cout << tar << Split;
#ifdef WRITE_ENDL
write();
#endif
} template<typename Head, typename T, typename... Tail>
extern inline void write(char Split, Head head, T mid, Tail... tail){
#ifdef SPLIT_WRITE
cout << head << Split;
#else
cout << head;
#endif
write(Split, mid, tail...);
} #else template <typename T>
extern inline void write(char Split, T tar){
cout << tar << Split;
#ifdef WRITE_ENDL
write();
#endif
} #endif #endif template <typename T>
extern inline void upmax(T &x, const T &y){
if(x < y) x = y;
}
template <typename T>
extern inline void upmin(T &x, const T &y){
if(x > y) x = y;
} #if __cplusplus >= 201103L template<typename T>
extern inline T max(T tar){
return tar;
} template<typename T>
extern inline T min(T tar){
return tar;
} template <typename Head, typename T, typename... Tail>
extern inline Head max(Head head, T mid, Tail... tail){
Head tmp = max(mid, tail...);
return head > tmp ? head : tmp;
}
template <typename Head, typename T, typename... Tail>
extern inline Head min(Head head, T mid, Tail... tail){
Head tmp = min(mid, tail...);
return head < tmp ? head : tmp;
} #else template <typename T>
extern inline T max(T a, T b){
return a > b ? a : b;
}
template <typename T>
extern inline T min(T a, T b){
return a < b ? a : b;
} #endif template <typename T>
extern inline T abs(T tar){
return tar < ? -tar : tar;
}
template <typename T>
extern inline void swap(T &a, T &b){
T t = a;
a = b;
b = t;
}
#ifdef NAME_SPACE
}
#endif //Algorithm #ifdef NAME_SPACE
namespace LKF{
#endif template <typename T>
struct Queue{
size_t s, t;
T *q;
Queue(){
s = , t = ;
q = NULL;
}
Queue(size_t siz){
s = , t = ;
q = (T*)malloc(sizeof(T) * siz);
assert(q != NULL);
}
inline void Re_Init(size_t siz){
q = (T*)realloc(q, sizeof(T) * siz);
assert(q != NULL);
}
~Queue(){
delete[] q;
}
inline void clear(){
s = , t = ;
}
inline bool empty(){
return s > t;
}
inline size_t size(){
return t - s + ;
}
inline void push(T tar){
q[++ t] = tar;
}
inline void pop_front(){
s ++;
}
inline void pop_back(){
t --;
}
inline T front(){
return q[s];
}
inline T back(){
return q[t];
}
}; template <typename T>
struct Stack{
size_t t;
T *s;
Stack(){
t = ;
s = NULL;
}
Stack(size_t siz){
t = ;
s = (T*)malloc(sizeof(T) * siz);
assert(s != NULL);
}
inline void Re_Init(size_t siz){
s = (T*)realloc(s, sizeof(T) * siz);
assert(s != NULL);
}
~Stack(){
delete[] s;
}
inline void clear(){
t = ;
}
inline bool empty(){
return t == ;
}
inline size_t size(){
return t;
}
inline void push(T tar){
s[++ t] = tar;
}
inline T top(){
return s[t];
}
inline void pop(){
t --;
}
}; #ifdef NAME_SPACE
}
#endif #ifdef USING #ifdef NAME_SPACE
using LKF::pc;
using LKF::read_ch;
using LKF::read_dec;
using LKF::read;
using LKF::Main_Init;
using LKF::write;
using LKF::upmax;
using LKF::upmin;
using LKF::max;
using LKF::min;
using LKF::abs;
// using LKF::swap;
#else
using ::pc;
using ::read_ch;
using ::read_dec;
using ::read;
using ::Main_Init;
using ::write;
using ::upmax;
using ::upmin;
using ::max;
using ::min;
using ::abs;
// using ::swap;
#endif #endif //Source Code //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Debug_Part~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#if DEBUG //Caution: Do Not Inline
//Do Not Open In Dev_CPP
//Please Compile it at LEAST in std=c++11
//This is the Release Version void Print_Array(int s, int t, int *arr, string Name){
cout << Name << " Begin" << endl;
for(int i = s; i < t; i++) cout << arr[i] << ' ';
cout << Name << " End" << endl;
} template <typename T>
void Print_List(T B, T E, string Name){
cout << Name << " Begin" << endl;
for(T it = B; it != E; it++)
cout << it -> x << ' ';
cout << endl << Name << " End" << endl;
} #endif
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Read_Part~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /*char buf[1000001], *pc = buf; extern inline void Main_Init(){
#if DEBUG
// freopen("in.in", "r", stdin);
// freopen("TIT.out", "w", stdout);
#endif
fread(buf, 1, 1000000, stdin);
} extern inline char get_char(){
return *pc++;
} extern inline void unget_char(){
pc--;
} inline int read(){
int num = 0;
char c;
while((c = get_char()) < 48);
while(num = num * 10 + c - 48, (c = get_char()) >= 48);
return num;
}*/ //Caution::
//Do not omit parentheses //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Defination_Part~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /*#ifdef max
#undef max
#endif #ifdef swap
#undef swap
#endif #ifdef min
#undef min
#endif*/ const int MAXN = , MAXS = , MAXT = ;
const int ING = , GO = ;//游戏状态
const int Step_CXX[][] = {{, }, {, }, {, -}, {-, }, {, }};//注意:已排序 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Variable_Part~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int N, M, S, D, R, T, Time, tot, Ant, Game_State;
vector<int> In_Tower[MAXN][MAXN];
bool Forbid[MAXN][MAXN], Ori[MAXN][MAXN];
int Pher[MAXN][MAXN];//由于地图要进行数组操作,所以不存结构体
int Pow[], X_IN[MAXN], Y_IN[MAXN];
bool Is_Cake = true; template <typename X, typename Y>
struct P{
X x;
Y y;
P(){}
P(X _x, Y _y){x = _x, y = _y;}
}; struct A{
int Level, Birth, Health, Survival;
bool Cake, Death;
P<int, int> Pos, LPos;
inline bool operator < (const A &tar) const {
return Survival > tar.Survival;
}
}; P<int, int> Towers[MAXS]; struct T{
int Target;
vector<P<int, double> > In_T;
}Tower[MAXS]; list<A> Ants;
list<A>::iterator Pross[MAXN]; inline bool cmp (const P<int, double> &a, const P<int, double> &b){//注意,这里的<为防御塔设计,x为蚂蚁编号,y为距离
return a.y == b.y ? Pross[a.x] -> Birth < Pross[b.x] -> Birth : a.y < b.y;
} //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Mini_Function__Part~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /*template <typename T>
extern inline T min(T a, T b){
return a < b ? a : b;
} template <typename T>
extern inline T max(T a, T b){
return a > b ? a : b;
} template <typename T>
extern inline void swap(T &a, T &b){
T t = a;
a = b;
b = t;
}*/ template <typename T>
extern inline T pow_2(T tar){
return tar * tar;
} inline double Get_Dis(int x0, int y0, int x1, int y1){
return sqrt(pow_2(x0 - x1) + pow_2(y1 - y0));
} inline bool Is_Cross(int x, int y, int x1, int y1, int r1){
double dis = Get_Dis(x, y, x1, y1);
return dis <= double(r1);
} inline bool Can_Be_Hit(int x0, int y0, int x2, int y2, int x1, int y1){//圆信息+蚂蚁信息+线段末端
if((x2 == x0 && y2 == y0) || (x2 == x1 && y2 == y1)) return true;
int l1 = min(x0, x1), r1 = max(x0, x1), l2 = min(y0, y1), r2 = max(y0, y1);
if(x2 < l1 || x2 > r1 || y2 < l2 || y2 > r2) return false;
// int s1 = x2 > x0 ? 1 : -1, s2 = y2 > y0 ? 1 : -1;//注意圆的半径是谁的
// if(!(s1 * x0 <= s1 * x1 && s1 * x1 <= s1 * x2) && (s2 * y0 <= s2 * y1 && s2 * y1 <= s2 * y2)) return false;
// if(x1 == x0) return double(abs(x1 - x2)) <= 0.5;
if(x1 == x0) return abs(x1 - x0) <= 0.5;
double r = 0.5, k = double(1.0 * (y1 - y0) / (x1 - x0)), b = double(1.0 * y0 - double(x0 * k));
double p1 = pow_2(k * x2 - y2 + b);
double p2 = r * r * (k * k + );
return p1 <= p2;
// double p1 = pow_2(double(2 * k * b - 2 * x0 * x0 - 2 * y0 * k));
// double p2 = double(4 * (k * k + 1) * (x0 * x0 + b * b + y0 * y0 - 2 * y0 * b - r * r));
// return p2 - p1 >= 0;
} //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Declaring_Part~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inline void Input(); inline void Solve(); inline void Output(); inline void Add_Ants(); inline int Move_Ants(); inline void New_Round(); inline void Start_Round(); inline void Pre_Treat_Tower(); inline void End_Round(); inline void Cal_Tar(); inline void Attack(int); inline void Dec_Health(); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Main_Part~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int main(){
Main_Init();
Input();
Solve();
Output();
return ;
} //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Function_Part~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inline void Input(){
N = read() + , M = read() + , S = read(), D = read(), R = read();
for(int i = ; i <= S; i++){
Towers[i].x = read() + , Towers[i].y = read() + ;
}
T = read();
} inline void Add_Ants(){
A In;
++tot;
In.Birth = Time, In.Level = (tot - ) / + , In.Health = Pow[In.Level], In.Survival = , In.Cake = false;
In.Death = false;
In.LPos = In.Pos = P<int, int>(, );
Ants.push_back(In);
} inline void Pre_Treat_Tower(){
for(int k = ; k <= S; k++){
int x = Towers[k].x, y = Towers[k].y;
Ori[x][y] = true;
for(int i = ; i <= N; i++){
for(int j = ; j <= M; j++){
if(Get_Dis(x, y, i, j) <= R){
In_Tower[i][j].push_back(k);
}
}
}
/*
Ori[x][y] = true;
for(int j = 0; j < R; j++){
int x0 = x - R + j, x1 = x + R - j;
int ys = y - j;
for(int k = 1; k <= (j << 1) + 1; k++){
if(ys + k - 1 <= 0 || ys + k - 1 > M) continue;
if(x0 > 0 && x0 <= N)
In_Tower[x0][ys + k - 1].push_back(i);
if(x1 > 0 && x1 <= N)
In_Tower[x1][ys + k - 1].push_back(i);
}
}
for(int j = y - R; j <= y + R; j++)
In_Tower[x][j].push_back(i);*/
}
} inline int Move_Ants(){
int cake = ;
for(int i = ; i <= Ant; i++){//不知道要不要移走出生点的
// if(Pross[i] -> Birth == Time) continue;
int x = (Pross[i] -> Pos).x, y = (Pross[i] -> Pos).y, Dir = , Max_D = ;
Forbid[x][y] = false;
for(int j = ; j < ; j++){
int tx = x + Step_CXX[j][], ty = y + Step_CXX[j][];
if(Forbid[tx][ty] || (tx == Pross[i] -> LPos.x && ty == Pross[i] -> LPos.y)) continue;
if(Dir == || Pher[tx][ty] > Max_D) Max_D = Pher[tx][ty], Dir = j;
}
if(Dir != ){
if(Pross[i] -> Survival % == ){
for(int j = ; j < ; j++){
int k = (Dir - j + ) % ;
int tx = x + Step_CXX[k][], ty = y + Step_CXX[k][];
if(!Forbid[tx][ty] && (tx != Pross[i] -> LPos.x || ty != Pross[i] -> LPos.y)){//逻辑运算
Dir = k;
break;
}
}
}
}
Pross[i] -> LPos.x = x, Pross[i] -> LPos.y = y;
(Pross[i] -> Pos).x = x = x + Step_CXX[Dir][], (Pross[i] -> Pos).y = y = y + Step_CXX[Dir][];
Forbid[x][y] = true;
if(x == N && y == M && Is_Cake){
Pross[i] -> Health = min(Pow[Pross[i] -> Level], Pross[i] -> Health + (Pow[Pross[i] -> Level] >> ));
Pross[i] -> Cake = true, cake = i, Is_Cake = false;
}
}
return cake;
} inline void Start_Round(){
Time++;
memcpy(Forbid, Ori, sizeof(Forbid));
for(list<A>::iterator it = Ants.begin(); it != Ants.end(); it++){
Forbid[it -> Pos.x][it -> Pos.y] = true;
}
if(Ants.size() < && !Forbid[][])
Add_Ants(), Forbid[][] = true;
Ant = ;
for(list<A>::iterator it = Ants.begin(); it != Ants.end(); it++){
Pross[++Ant] = it;
Pher[Pross[Ant] -> Pos.x][Pross[Ant] -> Pos.y] += + Pross[Ant] -> Cake * ;
}
} inline void End_Round(){
for(list<A>::iterator it = Ants.begin(); it != Ants.end(); it++){
if(!it -> Death && it -> Cake && it -> Pos.x == && it -> Pos.y == ){
Game_State = GO;
return ;
}
}
for(list<A>::iterator it = Ants.begin(); it != Ants.end(); it++){
it -> Survival++;
}
for(int i = ; i <= N; i++){
for(int j = ; j <= M; j++){
Pher[i][j] = max(Pher[i][j] - , );
}
}
} inline void Attack(int Cake_Tar){
for(int i = ; i <= S; i++){
Tower[i].Target = ;
Tower[i].In_T.clear();
}
for(int i = ; i <= Ant; i++){
int x = Pross[i] -> Pos.x, y = Pross[i] -> Pos.y, size = In_Tower[x][y].size();
// printf("In Time %d, %d on (%d, %d) With %d Who born in %d\n", Time, i, x, y, Pross[i] -> Health, Pross[i] -> Birth);
for(int j = ; j < size; j++){
int tar = In_Tower[x][y][j];
Tower[tar].In_T.push_back(P<int, double>(i, Get_Dis(x, y, Towers[tar].x, Towers[tar].y)));
if(Pross[i] -> Cake) Tower[tar].Target = i;
}
}
// printf("%d %d\n", Pross[1] -> Pos.x, Pross[1] -> Pos.y);
// Print_List(Tower[1].In_T.begin(), Tower[1].In_T.end(), "In_T");
for(int i = ; i <= S; i++){
if(Tower[i].Target) goto Att_Label;
if(Tower[i].In_T.empty()) continue;
sort(Tower[i].In_T.begin(), Tower[i].In_T.end(), cmp);
Tower[i].Target = Tower[i].In_T.front().x;
Att_Label:for(auto j = Tower[i].In_T.begin(); j != Tower[i].In_T.end(); j++){
// double Debug = j -> y;
if(j -> x == Tower[i].Target ||
Can_Be_Hit(Towers[i].x - , Towers[i].y - , Pross[j -> x] -> Pos.x - , Pross[j -> x] -> Pos.y - , Pross[Tower[i].Target] -> Pos.x - , Pross[Tower[i].Target] -> Pos.y - )){
Pross[j -> x] -> Health -= D;
// printf("In Time %d, %d on (%d, %d) Was Attacked by %d\n", Time, j -> x, Pross[j -> x] -> Pos.x, Pross[j -> x] -> Pos.y, i);
}
}
}
for(int i = ; i <= Ant; i++){
if(Pross[i] -> Health < ){
Pross[i] -> Death = true;
if(Pross[i] -> Cake) Is_Cake = true;
}
}
bool flag = true;
while(flag){
flag = false;
for(list<A>::iterator it = Ants.begin(); it != Ants.end(); it++){
if(it -> Death){
flag = true;
Ants.erase(it);
break;
}
}
}
} inline void New_Round(){
Start_Round();
Attack(Move_Ants());
End_Round();
} inline void Solve(){//整理事件是个不错的方法
Can_Be_Hit(, , , , , );
Pre_Treat_Tower();
for(int i = ; i <= M; i++) Ori[][i] = Ori[N + ][i] = true;
for(int i = ; i <= N; i++) Ori[i][] = Ori[i][M + ] = true;
double pow11[];
pow11[] = ;
for(int i = ; i <= ; i++){
pow11[i] = pow11[i - ] * 1.1;
Pow[i] = pow11[i] * ;
}
while(Time < T && Game_State == ING)
New_Round();
} inline void Output(){
if(Time < T || Game_State == GO) printf("Game over after %d seconds\n", Time);
else puts("The game is going on");
printf("%d\n", Ants.size());
Ants.sort();
for(auto it : Ants){
printf("%d %d %d %d %d\n", it.Survival - , it.Level, it.Health, it.Pos.x - , it.Pos.y - );
}
}

Source Code

Luogu2586 [ZJOI2008]杀蚂蚁 ---- 模拟的更多相关文章

  1. P2586 [ZJOI2008]杀蚂蚁(模拟)

    P2586 [ZJOI2008]杀蚂蚁 大模拟. 什么都不想补了. 看变量名感性理解吧 #include<iostream> #include<cstdio> #include ...

  2. [BZOJ 1033][ZJOI2008]杀蚂蚁antbuster

    1033: [ZJOI2008]杀蚂蚁antbuster Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1200  Solved: 507[Submi ...

  3. [ZJOI2008]杀蚂蚁antbuster

    [ZJOI2008]杀蚂蚁antbuster 题目 最近,佳佳迷上了一款好玩的小游戏:antbuster.游戏规则非常简单:在一张地图上,左上角是蚂蚁窝,右下角是蛋糕,蚂蚁会源源不断地从窝里爬出来,试 ...

  4. BZOJ1033:[ZJOI2008]杀蚂蚁antbuster(模拟)

    Description 最近,佳佳迷上了一款好玩的小游戏:antbuster.游戏规则非常简单:在一张地图上,左上角是蚂蚁窝,右 下角是蛋糕,蚂蚁会源源不断地从窝里爬出来,试图把蛋糕搬回蚂蚁窝.而你的 ...

  5. 【BZOJ 1033】 [ZJOI2008]杀蚂蚁antbuster

    Description 最近,佳佳迷上了一款好玩的小游戏:antbuster.游戏规则非常简单:在一张地图上,左上角是蚂蚁窝,右下角是蛋糕,蚂蚁会源源不断地从窝里爬出来,试图把蛋糕搬回蚂蚁窝.而你的任 ...

  6. bzoj千题计划121:bzoj1033: [ZJOI2008]杀蚂蚁antbuster

    http://www.lydsy.com/JudgeOnline/problem.php?id=1033 经半个下午+一个晚上+半个晚上 的 昏天黑地调代码 最终成果: codevs.洛谷.tyvj上 ...

  7. [bzoj1033] [ZJOI2008]杀蚂蚁antbuster

    Description 最近,佳佳迷上了一款好玩的小游戏:antbuster.游戏规则非常简单:在一张地图上,左上角是蚂蚁窝,右下角是蛋糕,蚂蚁会源源不断地从窝里爬出来,试图把蛋糕搬回蚂蚁窝.而你的任 ...

  8. BZOJ1033:[ZJOI2008]杀蚂蚁

    我对模拟的理解:https://www.cnblogs.com/AKMer/p/9064018.html 题目传送门:https://www.lydsy.com/JudgeOnline/problem ...

  9. [ZJOI2008]杀蚂蚁

    题意翻译 注意在(0,0)已经有蚂蚁的时候是不会生成新蚂蚁的 还有如果有蚂蚁扛着蛋糕,但是不在某个炮的范围内,炮仍然会打最近的蚂蚁 题目描述 最近,佳佳迷上了一款好玩的小游戏:antbuster. 游 ...

随机推荐

  1. python读写文件字符集

    操作I/O的能力是由操作系统的提供的,每一种编程语言都会把操作系统提供的低级C接口封装起来供开发者使用,Python也不例外.  读写文件是需要请求操作系统去操作磁盘的  所以默认的编码就是你平台的编 ...

  2. HOG feature

  3. 理解 Linux 配置文件【转】

    转自:http://www.ibm.com/developerworks/cn/linux/management/configuration/ 分类和使用 本文说明了 Linux 系统的配置文件,在多 ...

  4. vim 超强发行版

    推荐第一个: https://github.com/spf13/spf13-vim https://github.com/Spacevim/Spacevim https://github.com/JB ...

  5. 【转】C Runtime Library的来历

    由于我看到的文章也是转载且未提供原文链接,所以这里没有提供原文链接! msvcrt.dll(名称:Microsoft C Runtime Library)提供了printf,malloc,strcpy ...

  6. JNI详解---从不懂到理解

    转载:https://blog.csdn.net/hui12581/article/details/44832651 Chap1:JNI完全手册... 3 Chap2:JNI-百度百科... 11 C ...

  7. Ex 6_5棋子放置问题_第八次作业

    题目貌似有问题 (b) 子问题定义: 设maxValue[i][j]为棋盘的前i行中最后一行为i时第i行按照第j种放置方式放置时得到的最大覆盖值,comp[i][j]为第i种放置方式与第j种放置方式是 ...

  8. Oracle查询表主键、外键

    项目中用到的一些Sql(oracle下的)总结: 1.查找表的所有索引(包括索引名,类型,构成列) select t.*,i.index_type from user_ind_columns t,us ...

  9. VirtualBox虚拟机安装Mac OS 10.12

    注:本文作者  (QQ:85805214) 本博主只是转载发布而已. VMware 安装Mac OS 方法 由于Virtual Box拷贝文件比较麻烦,有时候经常出现拷贝失败的情况,故使用VMware ...

  10. 自适应电脑、手机和iPad的网页设计方法

    随着3G的普及,越来越多的人使用手机上网. 移动设备正超过桌面设备,成为访问互联网的最常见终端.于是,网页设计师不得不面对一个难题:如何才能在不同大小的设备上呈现同样的网页? 手机的屏幕比较小,宽度通 ...