Luogu2586 [ZJOI2008]杀蚂蚁 ---- 模拟
Luogu2586 [ZJOI2008]杀蚂蚁
题意
还是一道大模拟
https://www.luogu.org/problemnew/show/P2586
大概就是炮塔大蚂蚁的故事
下载这个游戏http://www.antbuster.net/Antbuster_12k_20090824.swf
还是比较难玩的
题解
就是预处理塔能打到的位置,然后直接把一局游戏分成几个阶段,同时每个阶段做了什么事也比较清楚,然后思路就比较清晰
一些经验:
- 尽量预处理一些静态的东西,然后不要临时算,这样会把整个函数弄得比较杂乱
- 容器什么的其实在Linux内是可以直接查看的,但是依然推荐通过运行输出查看,因为这样有一个跟踪容器变化的效果
- 每次更改代码之后记录一下改了什么地方,或者是版本控制
- 逻辑错误GDB不可行
- 然后这次精简了一些函数,可能对于整体效果来说还是比较可以的
//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]杀蚂蚁 ---- 模拟的更多相关文章
- P2586 [ZJOI2008]杀蚂蚁(模拟)
P2586 [ZJOI2008]杀蚂蚁 大模拟. 什么都不想补了. 看变量名感性理解吧 #include<iostream> #include<cstdio> #include ...
- [BZOJ 1033][ZJOI2008]杀蚂蚁antbuster
1033: [ZJOI2008]杀蚂蚁antbuster Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 1200 Solved: 507[Submi ...
- [ZJOI2008]杀蚂蚁antbuster
[ZJOI2008]杀蚂蚁antbuster 题目 最近,佳佳迷上了一款好玩的小游戏:antbuster.游戏规则非常简单:在一张地图上,左上角是蚂蚁窝,右下角是蛋糕,蚂蚁会源源不断地从窝里爬出来,试 ...
- BZOJ1033:[ZJOI2008]杀蚂蚁antbuster(模拟)
Description 最近,佳佳迷上了一款好玩的小游戏:antbuster.游戏规则非常简单:在一张地图上,左上角是蚂蚁窝,右 下角是蛋糕,蚂蚁会源源不断地从窝里爬出来,试图把蛋糕搬回蚂蚁窝.而你的 ...
- 【BZOJ 1033】 [ZJOI2008]杀蚂蚁antbuster
Description 最近,佳佳迷上了一款好玩的小游戏:antbuster.游戏规则非常简单:在一张地图上,左上角是蚂蚁窝,右下角是蛋糕,蚂蚁会源源不断地从窝里爬出来,试图把蛋糕搬回蚂蚁窝.而你的任 ...
- bzoj千题计划121:bzoj1033: [ZJOI2008]杀蚂蚁antbuster
http://www.lydsy.com/JudgeOnline/problem.php?id=1033 经半个下午+一个晚上+半个晚上 的 昏天黑地调代码 最终成果: codevs.洛谷.tyvj上 ...
- [bzoj1033] [ZJOI2008]杀蚂蚁antbuster
Description 最近,佳佳迷上了一款好玩的小游戏:antbuster.游戏规则非常简单:在一张地图上,左上角是蚂蚁窝,右下角是蛋糕,蚂蚁会源源不断地从窝里爬出来,试图把蛋糕搬回蚂蚁窝.而你的任 ...
- BZOJ1033:[ZJOI2008]杀蚂蚁
我对模拟的理解:https://www.cnblogs.com/AKMer/p/9064018.html 题目传送门:https://www.lydsy.com/JudgeOnline/problem ...
- [ZJOI2008]杀蚂蚁
题意翻译 注意在(0,0)已经有蚂蚁的时候是不会生成新蚂蚁的 还有如果有蚂蚁扛着蛋糕,但是不在某个炮的范围内,炮仍然会打最近的蚂蚁 题目描述 最近,佳佳迷上了一款好玩的小游戏:antbuster. 游 ...
随机推荐
- pandas 定位 loc,iloc,ix
In [114]: df Out[114]: A B C D 2018-06-30 0.318501 0.613145 0.485612 0.918663 2018-07-31 0.614796 0. ...
- VMware xp系统联网
1.
- kali Linux下wifi密码安全测试(1)虚拟机下usb无线网卡的挂载 【转】
转自:http://blog.chinaunix.net/uid-26349264-id-4455634.html 目录 kali Linux下wifi密码安全测试(1)虚拟机下usb无线网卡的挂载 ...
- 一个优秀的 ring buffer 或 cycle buffer 的实现代码
#define CIRCLE_BUFFSIZE 1024 * 1024#define min(x, y) ((x) < (y) ? (x) : (y)) struct cycle_buffer ...
- setfacl报错Operation not supported
对文件目录setfacl权限设置时报错Operation not supported Google一下,发现是分区acl权限问题 一般情况下(ext4),默认acl支持都是加载的.但如果遇到二般情况, ...
- dubbo系列三、架构介绍及各模块关系
一.整体设计 图例说明: 图中左边淡蓝背景的为服务消费方使用的接口,右边淡绿色背景的为服务提供方使用的接口,位于中轴线上的为双方都用到的接口. 图中从下至上分为十层,各层均为单向依赖,右边的黑色箭头代 ...
- 改变input标签中placeholder显示的颜色
::-webkit-input-placeholder { /* WebKit browsers */ color: #A9A9A9; } :-moz-placeholder { /* Mozilla ...
- 深入浅出 JavaScript 关键词 -- this
深入浅出 JavaScript 关键词 -- this 要说 JavaScript 这门语言最容易让人困惑的知识点,this 关键词肯定算一个.JavaScript 语言面世多年,一直在进化完善,现在 ...
- alt-opt and end2end
关于两种训练方式的不同,论文中一种是4阶段训练,这种容易理解,还有一种是近似联合训练, 参考:http://jacobkong.github.io/posts/3802700508/ 关于两种训练方式 ...
- Windows不能在本地计算机启动MongoDB,错误代码 100
今天在计算机上面启动MongoDB时,直接给我报错,Windows不能在本地计算机启动MongoDB,服务错误代码 100. 这种问题解决方法是: 找到data文件夹db下面的mongod.lock文 ...