Cxxdgc's Site

Back

关于魔兽世界终极版#

  1. 关于dragon士气取小数点后两位的问题

这个我自己也没有研究明白他是一个什么机制,但是将士气用double类型替换float类型后是可以ac的。(详见代码中实现)

*学完ics相关内容后回来补一下:通俗的讲,编译器的四舍五入源于其理解该数“离谁更近”。一些情况下,float和double类型在数据储存时由于内存管理方式的差异,会导致其对.5数据的四舍五入出现不一致的问题。

*归结于这个题本身,可能是由于测试数据生成时使用的运行环境/数据类型与使用double类型并在openjudge上运行时结果不一致,导致使用double类型时无法ac。可以尝试不同的浮点数据类型。

  1. sword生成时即有可能攻击力为0,要在生成时进行检验

  2. 魔兽世界终极版测试数据量较大,如何快速发现wrong answer的点?

首先,在代码main函数开头添加以下片段将输出重定向到文件中(记得include fstream)

streambuf *orig_buf = std::cout.rdbuf();
ofstream out("output.txt");
if (out){
	std::cout.rdbuf(out.rdbuf());
}
c

接着便可以通过文本比对网站(推荐这个网站)来快速查看标准输出与你的输出的区别

一、魔兽世界之一:备战#

题目信息#

描述

魔兽世界的西面是红魔军的司令部,东面是蓝魔军的司令部。两个司令部之间是依次排列的若干城市。 红司令部,City 1,City 2,……,City n,蓝司令部

两军的司令部都会制造武士。武士一共有 dragon 、ninja、iceman、lion、wolf 五种。每种武士都有编号、生命值、攻击力这三种属性。

双方的武士编号都是从1开始计算。红方制造出来的第n个武士,编号就是n。同样,蓝方制造出来的第n个武士,编号也是n。

武士在刚降生的时候有一个生命值。

在每个整点,双方的司令部中各有一个武士降生。

红方司令部按照iceman、lion、wolf、ninja、dragon的顺序循环制造武士。

蓝方司令部按照lion、dragon、ninja、iceman、wolf的顺序循环制造武士。

制造武士需要生命元。

制造一个初始生命值为m的武士,司令部中的生命元就要减少m个。

如果司令部中的生命元不足以制造某个按顺序应该制造的武士,那么司令部就试图制造下一个。如果所有武士都不能制造了,则司令部停止制造武士。

给定一个时间,和双方司令部的初始生命元数目,要求你将从0点0分开始到双方司令部停止制造武士为止的所有事件按顺序输出。 一共有两种事件,其对应的输出样例如下:

  1. 武士降生

输出样例: 004 blue lion 5 born with strength 5,2 lion in red headquarter

表示在4点整,编号为5的蓝魔lion武士降生,它降生时生命值为5,降生后蓝魔司令部里共有2个lion武士。(为简单起见,不考虑单词的复数形式)注意,每制造出一个新的武士,都要输出此时司令部里共有多少个该种武士。

  1. 司令部停止制造武士

输出样例: 010 red headquarter stops making warriors

表示在10点整,红方司令部停止制造武士

输出事件时:

首先按时间顺序输出;

同一时间发生的事件,先输出红司令部的,再输出蓝司令部的。

输入

第一行是一个整数,代表测试数据组数。

每组测试数据共两行。

第一行:一个整数M。其含义为, 每个司令部一开始都有M个生命元( 1 <= M <= 10000)。

第二行:五个整数,依次是 dragon 、ninja、iceman、lion、wolf 的初始生命值。它们都大于0小于等于10000。 输出

对每组测试数据,要求输出从0时0分开始,到双方司令部都停止制造武士为止的所有事件。

对每组测试数据,首先输出”Case:n” n是测试数据的编号,从1开始 。

接下来按恰当的顺序和格式输出所有事件。每个事件都以事件发生的时间开头,时间以小时为单位,有三位。

样例输入

1
20
3 4 5 6 7
plaintext

样例输出

Case:1
000 red iceman 1 born with strength 5,1 iceman in red headquarter
000 blue lion 1 born with strength 6,1 lion in blue headquarter
001 red lion 2 born with strength 6,1 lion in red headquarter
001 blue dragon 2 born with strength 3,1 dragon in blue headquarter
002 red wolf 3 born with strength 7,1 wolf in red headquarter
002 blue ninja 3 born with strength 4,1 ninja in blue headquarter
003 red headquarter stops making warriors
003 blue iceman 4 born with strength 5,1 iceman in blue headquarter
004 blue headquarter stops making warriors
plaintext

代码#

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;


const string wushi_mode[5] = { "dragon","ninja","iceman","lion","wolf" };//武士种类名称
const string group_color[2] = { "red","blue" };//阵营颜色
const int the_num_of_group_color = 2;//阵营的数量
const int the_num_of_wushi_mode=5;//武士种类的数量
const int the_create_num_of_the_slb_to_wushi[2][5] = { {2,3,4,1,0},{3,0,1,2,4} };
bool flag_create_wushi[2] = { 0 };
int wushi_HP_init[5], wushi_HP_min;//各种武士初始生命值
int time_total=0;//游戏总时间


class wushi {
private:
	int HP, group, mode,time_appear,num;
public:
	wushi(int i, int j, int k,int m,int l):HP(i),group(j),mode(k),time_appear(m),num(l) 
	{//HP生命值,group阵营,0红1蓝,mode表示怪物种类,time_appear表示武士生成时间,num为编号
		wushi_appear_debug(i, j, k, m,l);
	}

	void wushi_appear_debug(int i, int j, int k, int m,int l) {//输出刚刚生成的武士信息
		cout << setw(3) << setfill('0') << time_appear << " " << group_color[group] << " " << wushi_mode[mode] << " " << num << " born with strength " << HP << ",";
	};
};

class silingbu {
private:
	int HP;
	int name;
	int wushi_num[the_num_of_wushi_mode] = { 0 },wushi_sum=0;//表示各种武士数量和武士总数量
	int wushi_num_create=0;//表示即将尝试生成的武士编号(映射前)
public:
	silingbu(int i, int j) :HP(i), name(j) {//HP表示司令部剩余生命值,name表示司令部编号
		
	}
	int HP_f() { return HP; }
	
	
	void silingbu_wushi_create() {//武士生成
		if (HP < wushi_HP_min) {
			cout << setw(3) << setfill('0') << time_total << " " << group_color[name] << " headquarter stops making warriors" << endl;
			flag_create_wushi[name] = 1;
			return;
		}
		while (wushi_HP_init[the_create_num_of_the_slb_to_wushi[name][wushi_num_create]] > HP) {
			wushi_num_create = (wushi_num_create + 1) % the_num_of_wushi_mode;
		}
		wushi w(wushi_HP_init[the_create_num_of_the_slb_to_wushi[name][wushi_num_create]],name, the_create_num_of_the_slb_to_wushi[name][wushi_num_create],time_total,wushi_sum+1);
		wushi_sum++; wushi_num[the_create_num_of_the_slb_to_wushi[name][wushi_num_create]]++; HP -= wushi_HP_init[the_create_num_of_the_slb_to_wushi[name][wushi_num_create]];
		slb_ws_create_debug(the_create_num_of_the_slb_to_wushi[name][wushi_num_create]);
		wushi_num_create = (wushi_num_create + 1) % the_num_of_wushi_mode;
	}

	void slb_ws_create_debug(int wushi_num_create) {//输出当前阵营的某种武士数量和
		cout<<wushi_num[wushi_num_create] << " " << wushi_mode[wushi_num_create] << " in " << group_color[name] << " headquarter" << endl;
	}

};

void game_init() {//全盘游戏初始化
	time_total = 0;
	flag_create_wushi[0] = 0;
	flag_create_wushi[1] = 0;
}

int main() {
	int n;
	cin >> n;
	for (int mhx_tql = 0; mhx_tql < n; mhx_tql++) {
		cout << "Case:" << mhx_tql + 1 << endl;
		game_init();
		int m;
		cin >> m;
		cin >> wushi_HP_init[0];
		wushi_HP_min = wushi_HP_init[0];
		for (int i = 1; i < 5; i++) {
			cin >> wushi_HP_init[i];
			wushi_HP_min = min(wushi_HP_init[i], wushi_HP_min);
		}
		silingbu red(m,0);
		silingbu blue(m,1);
		while (flag_create_wushi[0]==0 || flag_create_wushi[1]==0) {
			if (flag_create_wushi[0] == 0) {
				red.silingbu_wushi_create();
			}
			if (flag_create_wushi[1] == 0) {
				blue.silingbu_wushi_create();
			}
			time_total++;
		};
	}
}
plaintext

二、魔兽世界之二:装备#

题目信息#

描述

魔兽世界的西面是红魔军的司令部,东面是蓝魔军的司令部。两个司令部之间是依次排列的若干城市。

红司令部,City 1,City 2,……,City n,蓝司令部

两军的司令部都会制造武士。武士一共有 dragon 、ninja、iceman、lion、wolf 五种。每种武士都有编号、生命值这两种属性。 有的武士可以拥有武器。武器有三种,sword, bomb,和arrow,编号分别为0,1,2。 双方的武士编号都是从1开始计算。红方制造出来的第 n 个武士,编号就是n。同样,蓝方制造出来的第 n 个武士,编号也是n。

不同的武士有不同的特点。 dragon 可以拥有一件武器。编号为n的dragon降生时即获得编号为 n%3 的武器。dragon还有“士气”这个属性,是个浮点数,其值为它降生后其司令部剩余生命元的数量除以造dragon所需的生命元数量。 ninja可以拥有两件武器。编号为n的ninja降生时即获得编号为 n%3 和 (n+1)%3的武器。 iceman有一件武器。编号为n的iceman降生时即获得编号为 n%3 的武器。 lion 有“忠诚度”这个属性,其值等于它降生后其司令部剩余生命元的数目。 wolf没特点。 请注意,在以后的题目里,武士的士气,生命值,忠诚度在其生存期间都可能发生变化,都有作用,武士手中的武器随着使用攻击力也会发生变化。

武士在刚降生的时候有一个生命值。

在每个整点,双方的司令部中各有一个武士降生。

红方司令部按照 iceman、lion、wolf、ninja、dragon 的顺序循环制造武士。

蓝方司令部按照 lion、dragon、ninja、iceman、wolf 的顺序循环制造武士。

制造武士需要生命元。

制造一个初始生命值为 m 的武士,司令部中的生命元就要减少 m 个。

如果司令部中的生命元不足以制造某个按顺序应该制造的武士,那么司令部就试图制造下一个。如果所有武士都不能制造了,则司令部停止制造武士。 给定一个时间,和双方司令部的初始生命元数目,要求你将从0点0分开始到双方司令部停止制造武士为止的所有事件按顺序输出。 一共有两种事件,其对应的输出样例如下:

  1. 武士降生 输出样例: 004 blue lion 5 born with strength 5,2 lion in red headquarter 表示在 4点整,编号为5的蓝魔lion武士降生,它降生时生命值为5,降生后蓝魔司令部里共有2个lion武士。(为简单起见,不考虑单词的复数形式)注意,每制造出一个新的武士,都要输出此时司令部里共有多少个该种武士。 如果造出的是dragon,那么还要输出一行,例: It has a arrow,and it’s morale is 23.34 表示该dragon降生时得到了arrow,其士气是23.34(为简单起见,本题中arrow前面的冠词用a,不用an,士气精确到小数点后面2位,四舍五入) 如果造出的是ninja,那么还要输出一行,例: It has a bomb and a arrow 表示该ninja降生时得到了bomb和arrow。 如果造出的是iceman,那么还要输出一行,例: It has a sword 表示该iceman降生时得到了sword。 如果造出的是lion,那么还要输出一行,例: It’s loyalty is 24 表示该lion降生时的忠诚度是24。

  2. 司令部停止制造武士 输出样例: 010 red headquarter stops making warriors 表示在 10点整,红方司令部停止制造武士

输出事件时:

首先按时间顺序输出;

同一时间发生的事件,先输出红司令部的,再输出蓝司令部的。

输入

第一行是一个整数,代表测试数据组数。

每组测试数据共两行。

第一行,一个整数M。其含义为: 每个司令部一开始都有M个生命元( 1 <= M <= 10000)

第二行:五个整数,依次是 dragon 、ninja、iceman、lion、wolf 的初始生命值。它们都大于0小于等于10000 输出 对每组测试数据,要求输出从0时0分开始,到双方司令部都停止制造武士为止的所有事件。 对每组测试数据,首先输出“Case:n” n是测试数据的编号,从1开始 接下来按恰当的顺序和格式输出所有事件。每个事件都以事件发生的时间开头,时间以小时为单位,有三位。

样例输入

1
20
3 4 5 6 7
plaintext

样例输出

Case:1
000 red iceman 1 born with strength 5,1 iceman in red headquarter
It has a bomb
000 blue lion 1 born with strength 6,1 lion in blue headquarter
It's loyalty is 14
001 red lion 2 born with strength 6,1 lion in red headquarter
It's loyalty is 9
001 blue dragon 2 born with strength 3,1 dragon in blue headquarter
It has a arrow,and it's morale is 3.67
002 red wolf 3 born with strength 7,1 wolf in red headquarter
002 blue ninja 3 born with strength 4,1 ninja in blue headquarter
It has a sword and a bomb
003 red headquarter stops making warriors
003 blue iceman 4 born with strength 5,1 iceman in blue headquarter
It has a bomb
004 blue headquarter stops making warriors
plaintext

代码#

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;


const string wushi_mode[5] = { "dragon","ninja","iceman","lion","wolf" };//武士种类名称
const string group_color[2] = { "red","blue" };//阵营颜色
const int the_num_of_group_color = 2;//阵营的数量
const int the_num_of_wushi_mode=5;//武士种类的数量
const string weapon_mode[3] = { "sword","bomb","arrow" };
const int the_create_num_of_the_slb_to_wushi[2][5] = { {2,3,4,1,0},{3,0,1,2,4} };
bool flag_create_wushi[2] = { 0 };
int wushi_HP_init[5], wushi_HP_min;//各种武士初始生命值
int time_total=0;//游戏总时间

class silingbu;
void wushi_create_sum(int i,int j,int k,int m,int l);


class silingbu {
private:
	int HP;
	int name;
	int wushi_num[the_num_of_wushi_mode] = { 0 }, wushi_sum = 0;//表示各种武士数量和武士总数量
	int wushi_num_create = 0;//表示即将尝试生成的武士编号(映射前)
public:
	void silingbu_init(int i, int j) {//HP表示司令部剩余生命值,name表示司令部编号
		HP = i;
		name = j;
		wushi_num_create = 0;
		wushi_sum = 0;
		for (int i = 0; i < the_num_of_wushi_mode; i++) {
			wushi_num[i] = 0;
		}
	}

	int HP_f() { return HP; }


	void silingbu_wushi_create() {//武士生成
		if (HP < wushi_HP_min) {
			cout << setw(3) << setfill('0') << time_total << " " << group_color[name] << " headquarter stops making warriors" << endl;
			flag_create_wushi[name] = 1;
			return;
		}
		while (wushi_HP_init[the_create_num_of_the_slb_to_wushi[name][wushi_num_create]] > HP) {
			wushi_num_create = (wushi_num_create + 1) % the_num_of_wushi_mode;
		}
		wushi_create_sum(wushi_HP_init[the_create_num_of_the_slb_to_wushi[name][wushi_num_create]], name, the_create_num_of_the_slb_to_wushi[name][wushi_num_create], time_total, wushi_sum + 1);
	}

	void after_wushi_create() {
		wushi_sum++; wushi_num[the_create_num_of_the_slb_to_wushi[name][wushi_num_create]]++; HP -= wushi_HP_init[the_create_num_of_the_slb_to_wushi[name][wushi_num_create]];
		slb_ws_create_debug(the_create_num_of_the_slb_to_wushi[name][wushi_num_create]);
		wushi_num_create = (wushi_num_create + 1) % the_num_of_wushi_mode;
	}


	void slb_ws_create_debug(int wushi_num_create) {//输出当前阵营的某种武士数量和
		cout << wushi_num[wushi_num_create] << " " << wushi_mode[wushi_num_create] << " in " << group_color[name] << " headquarter" << endl;
	}

};


silingbu red,blue;




class wushi {
private:
	int HP, group, mode,time_appear,num;
public:
	wushi(int i, int j, int k,int m,int l):HP(i),group(j),mode(k),time_appear(m),num(l) 
	{//HP生命值,group阵营,0红1蓝,mode表示怪物种类,time_appear表示武士生成时间,num为编号
		wushi_appear_debug(i, j, k, m,l);
	}

	void wushi_appear_debug(int i, int j, int k, int m,int l) {//输出刚刚生成的武士信息+执行司令部后续操作
		cout << setw(3) << setfill('0') << time_appear << " " << group_color[group] << " " << wushi_mode[mode] << " " << num << " born with strength " << HP << ",";


		if (j == 0) {
			red.after_wushi_create();
		}
		else if (j == 1) {
			blue.after_wushi_create();
		}
		else {
			cout << "ERROR #2" << endl;
		}
	};
};

class wushi_dragon :public wushi {
private:
	int weapon;
	float shiqi;
public:
	wushi_dragon(int i, int j, int k, int m, int l) :wushi(i,j,k,m,l){
		//HP生命值,group阵营,0红1蓝,mode表示怪物种类,time_appear表示武士生成时间,num为编号
		weapon = l % 3;
		shiqi = float(j == 0 ? red.HP_f() : blue.HP_f()) / float(wushi_HP_init[0]);

		wushi_dragon_appear_debug();
	}

	void wushi_dragon_appear_debug() {
		cout << "It has a " << weapon_mode[weapon] << ",and it's morale is " << fixed << setprecision(2) << shiqi << endl;
	}
};

class wushi_ninja :public wushi {
private:
	int weapon_1, weapon_2;
public:
	wushi_ninja(int i, int j, int k, int m, int l) :wushi(i, j, k, m, l) {
		weapon_1 = l % 3;
		weapon_2 = (l + 1) % 3;
		
		wushi_ninja_appear_debug();
	}

	void wushi_ninja_appear_debug() {
		cout << "It has a " << weapon_mode[weapon_1] << " and a " << weapon_mode[weapon_2] << endl;
	}
};

class wushi_iceman :public wushi {
private:
	int weapon;
public:
	wushi_iceman(int i, int j, int k, int m, int l) :wushi(i, j, k, m, l) {
		weapon = l % 3;

		wushi_iceman_appear_debug();
	}

	void wushi_iceman_appear_debug() {
		cout << "It has a " << weapon_mode[weapon] << endl;
	}
};

class wushi_lion :public wushi {
private:
	int loyalty;
public:
	wushi_lion(int i, int j, int k, int m, int l) :wushi(i, j, k, m, l) {
		loyalty = (j == 0 ? red.HP_f() : blue.HP_f());

		wushi_lion_appear_debug();
	}

	void wushi_lion_appear_debug() {
		cout << "It's loyalty is " << loyalty << endl;
	}
};


class wushi_wolf :public wushi {
private:
	
public:
	wushi_wolf(int i, int j, int k, int m, int l) :wushi(i, j, k, m, l) {

		wushi_wolf_appear_debug();
	}

	void wushi_wolf_appear_debug() {

	}
};



void wushi_create_sum(int i, int j, int k, int m, int l) {
	if (k == 0) {
		wushi_dragon w(i, j, k, m, l);
	}
	else if (k == 1) {
		wushi_ninja w(i, j, k, m, l);
	}
	else if (k == 2) {
		wushi_iceman w(i, j, k, m, l);
	}
	else if (k == 3) {
		wushi_lion w(i, j, k, m, l);
	}
	else if (k==4){
		wushi_wolf w(i, j, k, m, l);
	}
	else {
		cout << "ERROR #1" << endl;
	}
}





void game_init() {//全盘游戏初始化
	time_total = 0;
	flag_create_wushi[0] = 0;
	flag_create_wushi[1] = 0;
}

int main() {
	int n;
	cin >> n;
	for (int mhx_tql = 0; mhx_tql < n; mhx_tql++) {
		cout << "Case:" << mhx_tql + 1 << endl;
		game_init();
		int m;
		cin >> m;
		cin >> wushi_HP_init[0];
		wushi_HP_min = wushi_HP_init[0];
		for (int i = 1; i < 5; i++) {
			cin >> wushi_HP_init[i];
			wushi_HP_min = min(wushi_HP_init[i], wushi_HP_min);
		}
		red.silingbu_init(m,0);
		blue.silingbu_init(m,1);
		while (flag_create_wushi[0]==0 || flag_create_wushi[1]==0) {
			if (flag_create_wushi[0] == 0) {
				red.silingbu_wushi_create();
			}
			if (flag_create_wushi[1] == 0) {
				blue.silingbu_wushi_create();
			}
			time_total++;
		};
	}
}
plaintext

三、魔兽世界三(开战)#

题目信息#

描述

魔兽世界的西面是红魔军的司令部,东面是蓝魔军的司令部。两个司令部之间是依次排列的若干城市,城市从西向东依次编号为1,2,3 … N ( N <= 20)。红魔军的司令部算作编号为0的城市,蓝魔军的司令部算作编号为N+1的城市。司令部有生命元,用于制造武士。

两军的司令部都会制造武士。武士一共有dragon 、ninja、iceman、lion、wolf 五种。每种武士都有编号、生命值、攻击力这三种属性。

双方的武士编号都是从1开始计算。红方制造出来的第n 个武士,编号就是n。同样,蓝方制造出来的第n 个武士,编号也是n。

武士在刚降生的时候有一个初始的生命值,生命值在战斗中会发生变化,如果生命值减少到0(生命值变为负数时应当做变为0处理),则武士死亡(消失)。

武士可以拥有武器。武器有三种,sword, bomb,和arrow,编号分别为0,1,2。

sword的攻击力是使用者当前攻击力的20%(去尾取整)。

bomb的攻击力是使用者当前攻击力的40%(去尾取整),但是也会导致使用者受到攻击,对使用者的攻击力是对敌人取整后的攻击力的1/2(去尾取整)。Bomb一旦使用就没了。

arrow的攻击力是使用者当前攻击力的30%(去尾取整)。一个arrow用两次就没了。

武士降生后就朝对方司令部走,在经过的城市如果遇到敌人(同一时刻每个城市最多只可能有1个蓝武士和一个红武士),就会发生战斗。战斗的规则是:

在奇数编号城市,红武士先发起攻击

在偶数编号城市,蓝武士先发起攻击

战斗开始前,双方先对自己的武器排好使用顺序,然后再一件一件地按顺序使用。编号小的武器,排在前面。若有多支arrow,用过的排在前面。排好序后,攻击者按此排序依次对敌人一件一件地使用武器。如果一种武器有多件,那就都要用上。每使用一件武器,被攻击者生命值要减去武器攻击力。如果任何一方生命值减为0或小于0即为死去。有一方死去,则战斗结束。

双方轮流使用武器,甲用过一件,就轮到乙用。某一方把自己所有的武器都用过一轮后,就从头开始再用一轮。如果某一方没有武器了,那就挨打直到死去或敌人武器用完。武器排序只在战斗前进行,战斗中不会重新排序。

如果双方武器都用完且都还活着,则战斗以平局结束。如果双方都死了,也算平局。

有可能由于武士自身攻击力太低,而导致武器攻击力为0。攻击力为0的武器也要使用。如果战斗中双方的生命值和武器的状态都不再发生变化,则战斗结束,算平局。

战斗的胜方获得对方手里的武器。武士手里武器总数不超过10件。缴获武器时,按照武器种类编号从小到大缴获。如果有多件arrow,优先缴获没用过的。

如果战斗开始前双方都没有武器,则战斗视为平局。如果先攻击方没有武器,则由后攻击方攻击。

不同的武士有不同的特点。

编号为n的dragon降生时即获得编号为n%3 的武器。dragon在战斗结束后,如果还没有战死,就会欢呼。

编号为n的ninjia降生时即获得编号为n%3 和(n+1)%3的武器。ninja 使用bomb不会让自己受伤。

编号为n的iceman降生时即获得编号为n%3 的武器。iceman每前进一步,生命值减少10%(减少的量要去尾取整)。

编号为n的lion降生时即获得编号为n%3 的武器。lion 有“忠诚度”这个属性,其初始值等于它降生之后其司令部剩余生命元的数目。每前进一步忠诚度就降低K。忠诚度降至0或0以下,则该lion逃离战场,永远消失。但是已经到达敌人司令部的lion不会逃跑。lion在己方司令部可能逃跑。

wolf降生时没有武器,但是在战斗开始前会抢到敌人编号最小的那种武器。如果敌人有多件这样的武器,则全部抢来。Wolf手里武器也不能超过10件。如果敌人arrow太多没法都抢来,那就先抢没用过的。如果敌人也是wolf,则不抢武器。

以下是不同时间会发生的不同事件:

在每个整点,即每个小时的第0分, 双方的司令部中各有一个武士降生。

红方司令部按照iceman、lion、wolf、ninja、dragon 的顺序制造武士。

蓝方司令部按照lion、dragon、ninja、iceman、wolf 的顺序制造武士。

制造武士需要生命元。

制造一个初始生命值为m 的武士,司令部中的生命元就要减少m 个。

如果司令部中的生命元不足以制造某本该造的武士,那就从此停止制造武士。

在每个小时的第5分,该逃跑的lion就在这一时刻逃跑了。

在每个小时的第10分:所有的武士朝敌人司令部方向前进一步。即从己方司令部走到相邻城市,或从一个城市走到下一个城市。或从和敌军司令部相邻的城市到达敌军司令部。

在每个小时的第35分:在有wolf及其敌人的城市,wolf要抢夺对方的武器。

在每个小时的第40分:在有两个武士的城市,会发生战斗。

在每个小时的第50分,司令部报告它拥有的生命元数量。

在每个小时的第55分,每个武士报告其拥有的武器情况。

武士到达对方司令部后就算完成任务了,从此就呆在那里无所事事。

任何一方的司令部里若是出现了敌人,则认为该司令部已被敌人占领。

任何一方的司令部被敌人占领,则战争结束。战争结束之后就不会发生任何事情了。

给定一个时间,要求你将从0点0分开始到此时间为止的所有事件按顺序输出。事件及其对应的输出样例如下:

  1. 武士降生

输出样例:000:00 blue dragon 1 born

表示在0点0分,编号为1的蓝魔dragon武士降生

如果造出的是lion,那么还要多输出一行,例:

000:00 blue lion 1 born

Its loyalty is 24

表示该lion降生时的忠诚度是24

  1. lion逃跑

输出样例:000:05 blue lion 1 ran away

表示在0点5分,编号为1的蓝魔lion武士逃走

  1. 武士前进到某一城市

输出样例:

000:10 red iceman 1 marched to city 1 with 20 elements and force 30

表示在0点10分,红魔1号武士iceman前进到1号城市,此时他生命值为20,攻击力为30

对于iceman,输出的生命值应该是变化后的数值

  1. wolf抢敌人的武器

000:35 blue wolf 2 took 3 bomb from red dragon 2 in city 4

表示在0点35分,4号城市中,红魔1号武士wolf 抢走蓝魔2号武士dragon 3个bomb。为简单起见,武器不写复数形式

  1. 报告战斗情况

战斗只有3种可能的输出结果:

000:40 red iceman 1 killed blue lion 12 in city 2 remaining 20 elements

表示在0点40分,1号城市中,红魔1号武士iceman 杀死蓝魔12号武士lion后,剩下生命值20

000:40 both red iceman 1 and blue lion 12 died in city 2

注意,把红武士写前面

000:40 both red iceman 1 and blue lion 12 were alive in city 2

注意,把红武士写前面

  1. 武士欢呼

输出样例:003:40 blue dragon 2 yelled in city 4

  1. 武士抵达敌军司令部

输出样例:001:10 red iceman 1 reached blue headquarter with 20 elements and force 30

(此时他生命值为20,攻击力为30)对于iceman,输出的生命值和攻击力应该是变化后的数值

  1. 司令部被占领

输出样例:003:10 blue headquarter was taken

9)司令部报告生命元数量

000:50 100 elements in red headquarter

000:50 120 elements in blue headquarter

表示在0点50分,红方司令部有100个生命元,蓝方有120个

10)武士报告情况

000:55 blue wolf 2 has 2 sword 3 bomb 0 arrow and 7 elements

为简单起见,武器都不写复数形式。elements一律写复数,哪怕只有1个

交代武器情况时,次序依次是:sword,bomb, arrow。

输出事件时:

首先按时间顺序输出;

同一时间发生的事件,按发生地点从西向东依次输出. 武士前进的事件, 算是发生在目的地。

在一次战斗中有可能发生上面的 5 至 6 号事件。这些事件都算同时发生,其时间就是战斗开始时间。一次战斗中的这些事件,序号小的应该先输出。

两个武士同时抵达同一城市,则先输出红武士的前进事件,后输出蓝武士的。

对于同一城市,同一时间发生的事情,先输出红方的,后输出蓝方的。

显然,8号事件发生之前的一瞬间一定发生了7号事件。输出时,这两件事算同一时间发生,但是应先输出7号事件

虽然任何一方的司令部被占领之后,就不会有任何事情发生了。但和司令部被占领同时发生的事件,全都要输出。

输入

第一行是t,代表测试数据组数

每组样例共三行。

第一行,4个整数 M,N,K, T。其含义为: 每个司令部一开始都有M个生命元( 1 <= M <= 100000) 两个司令部之间一共有N个城市( 1 <= N <= 20 ) lion每前进一步,忠诚度就降低K。(0<=K<=100) 要求输出从0时0分开始,到时间T为止(包括T) 的所有事件。T以分钟为单位,0 <= T <= 6000

第二行:五个整数,依次是 dragon 、ninja、iceman、lion、wolf 的初始生命值。它们都大于0小于等于200

第三行:五个整数,依次是 dragon 、ninja、iceman、lion、wolf 的攻击力。它们都大于0小于等于200

输出

对每组数据,先输出一行:

Case n:

如对第一组数据就输出 Case 1:

然后按恰当的顺序和格式输出到时间T为止发生的所有事件。每个事件都以事件发生的时间开头,时间格式是“时: 分”,“时”有三位,“分”有两位。

样例输入

1
20 1 10 400
20 20 30 10 20
5 5 5 5 5
plaintext

样例输出

Case 1:
000:00 blue lion 1 born
Its loyalty is 10
000:10 blue lion 1 marched to city 1 with 10 elements and force 5
000:50 20 elements in red headquarter
000:50 10 elements in blue headquarter
000:55 blue lion 1 has 0 sword 1 bomb 0 arrow and 10 elements
001:05 blue lion 1 ran away
001:50 20 elements in red headquarter
001:50 10 elements in blue headquarter
002:50 20 elements in red headquarter
002:50 10 elements in blue headquarter
003:50 20 elements in red headquarter
003:50 10 elements in blue headquarter
004:50 20 elements in red headquarter
004:50 10 elements in blue headquarter
005:50 20 elements in red headquarter
005:50 10 elements in blue headquarter
plaintext

提示

请注意浮点数精度误差问题。OJ上的编译器编译出来的可执行程序,在这方面和你电脑上执行的程序很可能会不一致。5 * 0.3 的结果,有的机器上可能是 15.00000001,去尾取整得到15,有的机器上可能是14.9999999,去尾取整后就变成14。因此,本题不要写 5 * 0.3,要写 5 * 3 / 10。

代码#

#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <deque>
#include <algorithm>
using namespace std;


const string wushi_mode[5] = { "dragon","ninja","iceman","lion","wolf" };//武士种类名称
const string group_color[2] = { "red","blue" };//阵营颜色
const int the_num_of_group_color = 2;//阵营的数量
const int the_num_of_wushi_mode = 5;//武士种类的数量
const string weapon_mode[3] = { "sword","bomb","arrow" };
const int the_create_num_of_the_slb_to_wushi[2][5] = { {2,3,4,1,0},{3,0,1,2,4} };//两大阵营生成武士顺序
bool flag_create_wushi[2] = { 0 };
int wushi_HP_init[5], wushi_HP_min;//各种武士初始生命值
int wushi_ATK_init[5];//武士初始攻击力
int time_total = 0;//游戏总时间
int time_goal;
int lion_k;
int city_amount;
class silingbu;
class wushi;
wushi* wushi_create_sum(int i, int j, int k, int m, int l);
void city_create_wushi(wushi* p, int group);
bool win_or_lose;



class silingbu {
private:
	int HP;
	int name;
	int wushi_num[the_num_of_wushi_mode] = { 0 }, wushi_sum = 0;//表示各种武士数量和武士总数量
	int wushi_num_create = 0;//表示即将尝试生成的武士编号(映射前)

public:
	vector<wushi*> warriors;
	void silingbu_init(int i, int j) {//HP表示司令部剩余生命值,name表示司令部编号
		HP = i;
		name = j;
		wushi_num_create = 0;
		wushi_sum = 0;
		for (int i = 0; i < the_num_of_wushi_mode; i++) {
			wushi_num[i] = 0;
		}
	}

	int HP_f() { return HP; }


	void silingbu_wushi_create() {//武士生成
		if (HP < wushi_HP_init[the_create_num_of_the_slb_to_wushi[name][wushi_num_create]]) {
			//cout << setw(3) << setfill('0') << time_total << " " << group_color[name] << " headquarter stops making warriors" << endl;
			flag_create_wushi[name] = 1;
			return;
		}
		/*
		while (wushi_HP_init[the_create_num_of_the_slb_to_wushi[name][wushi_num_create]] > HP) {
			wushi_num_create = (wushi_num_create + 1) % the_num_of_wushi_mode;
		}
		*/
		wushi* p;
		p = wushi_create_sum(wushi_HP_init[the_create_num_of_the_slb_to_wushi[name][wushi_num_create]], name, the_create_num_of_the_slb_to_wushi[name][wushi_num_create], time_total, wushi_sum + 1);
		warriors.push_back(p);
		city_create_wushi(p, name);
	}

	void after_wushi_create() {
		slb_ws_create_debug(wushi_HP_init[the_create_num_of_the_slb_to_wushi[name][wushi_num_create]], name, the_create_num_of_the_slb_to_wushi[name][wushi_num_create], time_total, wushi_sum + 1);
		wushi_sum++; wushi_num[the_create_num_of_the_slb_to_wushi[name][wushi_num_create]]++; HP -= wushi_HP_init[the_create_num_of_the_slb_to_wushi[name][wushi_num_create]];
		wushi_num_create = (wushi_num_create + 1) % the_num_of_wushi_mode;
	}


	void slb_ws_create_debug(int i, int j, int k, int m, int l) {//武士生成的信息输出
		//HP生命值,group阵营,0红1蓝,mode表示怪物种类,time_appear表示武士生成时间,num为编号
		//cout << wushi_num[wushi_num_create] << " " << wushi_mode[wushi_num_create] << " in " << group_color[name] << " headquarter" << endl;
		cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
		cout << group_color[j] << " " << wushi_mode[k] << " " << l << " born" << endl;
	}


	~silingbu() {
		/*
		for (auto i : warriors) {
			delete i;
			warriors.clear();
		}
		*/
	}
};


silingbu red, blue;

class weapon;

class wushi {
protected:
	int HP, group, mode, time_appear, num, atk;
	friend silingbu;
public:
	int weapons_num[3] = { 0 };
	vector <weapon*> weapons;
public:
	wushi(int i, int j, int k, int m, int l) :HP(i), group(j), mode(k), time_appear(m), num(l)
	{//HP生命值,group阵营,0红1蓝,mode表示怪物种类,time_appear表示武士生成时间,num为编号,atk攻击力
		atk = wushi_ATK_init[k];
		wushi_appear_debug(i, j, k, m, l);
	}

	int get_atk() {
		return atk;
	}

	void wushi_appear_debug(int i, int j, int k, int m, int l) {//输出刚刚生成的武士信息+执行司令部后续操作
		//cout << setw(3) << setfill('0') << time_appear << " " << group_color[group] << " " << wushi_mode[mode] << " " << num << " born with strength " << HP << ",";


		if (j == 0) {
			red.after_wushi_create();
		}
		else if (j == 1) {
			blue.after_wushi_create();
		}
		else {
			cout << "ERROR #2" << endl;
		}
	};
	void hurt(int harmness) {//受到攻击
		HP -= harmness;
	}

	virtual ~wushi() {
		for (auto i : weapons) {
			delete i;
			weapons.clear();
		}
	}
	int s_wushi_mode() {
		return mode;
	}
	int s_wushi_num() {
		return num;
	}
	int s_wushi_group() {
		return group;
	}
	int s_wushi_HP() {
		return HP;
	}
	int s_wushi_atk() {
		return atk;
	}
	virtual int dead_detect() {
		if (HP <= 0) {
			return 1;//1表示战死
		}
		else return 0;
	}

	virtual void after_forward() {

	}
};

wushi* city[30][2];


class weapon {
private:
	int broken;
public:
	weapon() {
		broken = 0;
	}
	void broke() {
		broken = 1;
	}
	//返回值1正常,0攻击失败,-1表示武器损毁
	virtual int attack(wushi* p1, wushi* p2) = 0;//p1为武器持有者,p2为武器目标
	//mode函数,0sword,1bomb,2arrow
	virtual int mode() = 0;
	virtual int s_unbreaking() {
		return -1;
	}
	virtual ~weapon() {

	}

};

class sword :public weapon {
public:
	virtual int attack(wushi* p1, wushi* p2) {
		p2->hurt(p1->get_atk() / 5);
		return 1;

	}
	virtual int mode() {
		return 0;
	}
};

class bomb :public weapon {
private:
	int unbreaking;
public:
	bomb() {
		unbreaking = 1;
	}
	virtual int attack(wushi* p1, wushi* p2) {
		p2->hurt(p1->get_atk() * 2 / 5);
		if (p1->s_wushi_mode() != 1) {//ninja使用炸弹自己不会受伤
			p1->hurt(p1->get_atk() / 5);
		}
		unbreaking--;
		broke();
		return -1;
	}
	virtual int s_unbreaking() {
		return unbreaking;
	}
	virtual int mode() {
		return 1;
	}

};

class arrow :public weapon {
private:
	int unbreaking;
public:
	arrow() {
		unbreaking = 2;
	}
	virtual int attack(wushi* p1, wushi* p2) {
		p2->hurt(p1->get_atk() * 3 / 10);
		unbreaking--;
		if (unbreaking <= 0) {
			broke();
			return -1;
		}
		return 1;
	}
	virtual int mode() {
		return 2;
	}
	virtual int s_unbreaking() {
		return unbreaking;
	}
};


bool cmp_weapons(weapon* p1, weapon* p2) {//武器排序规则
	if (p1->mode() != p2->mode()) {
		return p1->mode() < p2->mode();
	}
	if (p1->mode() == 2) {
		arrow* a1 = dynamic_cast<arrow*>(p1);
		arrow* a2 = dynamic_cast<arrow*>(p2);
		return (a1->s_unbreaking() < a2->s_unbreaking());
	}
	else {
		return false;
	}
}




weapon* weapon_generate(int mode) {
	weapon* p;
	if (mode == 0) {
		p = new sword;
	}
	else if (mode == 1) {
		p = new bomb;
	}
	else if (mode == 2) {
		p = new arrow;
	}
	else {
		cout << "ERROR!武器生成类型不匹配" << endl;
		p = nullptr;
	}
	return p;
}


class wushi_dragon :public wushi {
private:
	int _weapon;
	float shiqi;
public:
	wushi_dragon(int i, int j, int k, int m, int l) :wushi(i, j, k, m, l) {
		//HP生命值,group阵营,0红1蓝,mode表示怪物种类,time_appear表示武士生成时间,num为编号
		weapon* p;
		_weapon = l % 3;
		p = weapon_generate(l % 3);
		weapons.push_back(p);
		weapons_num[_weapon]++;

		shiqi = float(j == 0 ? red.HP_f() : blue.HP_f()) / float(wushi_HP_init[0]);
		wushi_dragon_appear_debug();
	}

	void wushi_dragon_appear_debug() {
		//cout << "It has a " << weapon_mode[_weapon] << ",and it's morale is " << fixed << setprecision(2) << shiqi << endl;
	}
};

class wushi_ninja :public wushi {
private:
	int weapon_1, weapon_2;
public:
	wushi_ninja(int i, int j, int k, int m, int l) :wushi(i, j, k, m, l) {
		weapon_1 = l % 3;
		weapon_2 = (l + 1) % 3;


		weapon* p1;
		weapon* p2;
		p1 = weapon_generate(l % 3);
		weapons.push_back(p1);
		weapons_num[weapon_1]++;
		p2 = weapon_generate((l + 1) % 3);
		weapons.push_back(p2);
		weapons_num[weapon_2]++;

		wushi_ninja_appear_debug();
	}

	void wushi_ninja_appear_debug() {
		//cout << "It has a " << weapon_mode[weapon_1] << " and a " << weapon_mode[weapon_2] << endl;
	}
};

class wushi_iceman :public wushi {
private:
	int _weapon;
public:
	wushi_iceman(int i, int j, int k, int m, int l) :wushi(i, j, k, m, l) {

		_weapon = l % 3;
		weapon* p1;
		p1 = weapon_generate(l % 3);
		weapons.push_back(p1);
		weapons_num[_weapon]++;

		wushi_iceman_appear_debug();
	}

	void wushi_iceman_appear_debug() {
		//cout << "It has a " << weapon_mode[_weapon] << endl;
	}

	virtual void after_forward() {
		HP -= HP / 10;
	}
};

class wushi_lion :public wushi {
private:
	int _weapon;
	int loyalty;
public:
	virtual int dead_detect() {
		if (HP <= 0) {
			return 1;
		}
		else if (loyalty <= 0) {
			return 2;
		}
		else return 0;
	}
	wushi_lion(int i, int j, int k, int m, int l) :wushi(i, j, k, m, l) {
		loyalty = (j == 0 ? red.HP_f() : blue.HP_f());

		_weapon = l % 3;
		weapon* p1;
		p1 = weapon_generate(l % 3);
		weapons_num[_weapon]++;

		weapons.push_back(p1);

		wushi_lion_appear_debug();
	}

	void wushi_lion_appear_debug() {
		cout << "Its loyalty is " << loyalty << endl;
	}

	virtual void after_forward() {
		loyalty -= lion_k;
	}

};


class wushi_wolf :public wushi {
private:

public:
	wushi_wolf(int i, int j, int k, int m, int l) :wushi(i, j, k, m, l) {

		wushi_wolf_appear_debug();
	}

	void wushi_wolf_appear_debug() {

	}
};



wushi* wushi_create_sum(int i, int j, int k, int m, int l) {
	wushi* p;
	if (k == 0) {
		p = new wushi_dragon(i, j, k, m, l);
	}
	else if (k == 1) {
		p = new wushi_ninja(i, j, k, m, l);
	}
	else if (k == 2) {
		p = new wushi_iceman(i, j, k, m, l);
	}
	else if (k == 3) {
		p = new wushi_lion(i, j, k, m, l);
	}
	else if (k == 4) {
		p = new wushi_wolf(i, j, k, m, l);
	}
	else {
		cout << "ERROR #1" << endl;
		p = nullptr;
	}
	return p;
}





void game_init() {//全盘游戏初始化
	time_total = 0;
	flag_create_wushi[0] = 0;
	flag_create_wushi[1] = 0;
	for (int i = 0; i < 22; i++) {
		for (int j = 0; j < 2; j++) {
			city[i][j] = nullptr;
		}
	}
	win_or_lose = false;
}




void timeline_lion_runaway() {//狮子逃跑
	//城市武士信息删除+输出
	for (int i = 1; i <= city_amount; i++) {
		for (int j = 0; j < 2; j++) {
			if (city[i][j] != nullptr) {
				//调试:cout << i << " " << j << endl;
				//调试:cout << city[i][j]->dead_detect() << endl;
				if (city[i][j]->dead_detect() == 2) {
					cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
					cout << group_color[city[i][j]->s_wushi_group()] << " " << wushi_mode[city[i][j]->s_wushi_mode()] << " " << city[i][j]->s_wushi_num() << " ran away" << endl;
					city[i][j] = nullptr;
				}
			}
		}
	}


	//从司令部武士信息中删除
	/*
	auto it = red.warriors.begin();
	while (it != red.warriors.end()) {
		if ((*it)->dead_detect()==2) {//狮子逃跑
			delete* it;
			it = red.warriors.erase(it);
		}
		else {
			++it;
		}
	}
	it = blue.warriors.begin();

	while (it != blue.warriors.end()) {
		if ((*it)->dead_detect()==2) {//狮子逃跑
			delete* it;
			it = blue.warriors.erase(it);
		}
		else {
			++it;
		}
	}
	*/
}

void city_create_wushi(wushi* p, int group) {//司令部位置武士处理
	if (group == 1) {
		city[city_amount + 1][1] = p;
	}
	else if (group == 0) {
		city[0][0] = p;
	}
	else
	{
		cout << "ERROR! #444" << endl;
	}
}

wushi* city_ys[22][2];

void wushi_forward() {//武士前进
	int i = 1;
	//复制一份武士数据供后面输出用
	for (int i = 0; i <= city_amount+1; i++) {
		for (int j = 0; j < 2; j++) {
			city_ys[i][j] = city[i][j];
		}
	}




	//实际的武士移动
	for (i = city_amount+1; i >= 1; i--) {
		if (city[i - 1][0] != nullptr) {
			city[i][0] = city[i - 1][0];
			city[i - 1][0] = nullptr;
			city[i][0]->after_forward();
		}
	}
	for (int i = 0; i <= city_amount; i++) {
		if (city[i + 1][1] != nullptr) {
			city[i][1] = city[i + 1][1];
			city[i + 1][1] = nullptr;
			city[i][1]->after_forward();
		}
	}

	//以上为实际操作部分,下面均为信息输出

	i = 1;
	
	if (city_ys[i][1] != nullptr) {


		cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
		cout << group_color[city_ys[i][1]->s_wushi_group()] << " " << wushi_mode[city_ys[i][1]->s_wushi_mode()] << " " << city_ys[i][1]->s_wushi_num() << " reached red headquarter";
		cout << " with " << city_ys[i][1]->s_wushi_HP() << " elements and force " << city_ys[i][1]->s_wushi_atk() << endl;


		cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
		cout << "red headquarter was taken" << endl;
		win_or_lose = true;
		
	}


	for (i = 1; i <= city_amount; i++) {
		if (city_ys[i - 1][0] != nullptr) {


			cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
			cout << group_color[city_ys[i - 1][0]->s_wushi_group()] << " " << wushi_mode[city_ys[i - 1][0]->s_wushi_mode()] << " " << city_ys[i - 1][0]->s_wushi_num() << " marched to city ";
			cout << i << " with " << city_ys[i - 1][0]->s_wushi_HP() << " elements and force " << city_ys[i - 1][0]->s_wushi_atk() << endl;
			/*
			city[i][0] = city[i - 1][0];
			city[i-1][0] = nullptr;
			city[i][0]->after_forward();
			*/

		}
		if (city_ys[i + 1][1] != nullptr) {
			//city[i][1] = city[i+1][1];

			cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
			cout << group_color[city_ys[i + 1][1]->s_wushi_group()] << " " << wushi_mode[city_ys[i + 1][1]->s_wushi_mode()] << " " << city_ys[i + 1][1]->s_wushi_num() << " marched to city ";
			cout << i << " with " << city_ys[i + 1][1]->s_wushi_HP() << " elements and force " << city_ys[i + 1][1]->s_wushi_atk() << endl;

			//city[i+1][1] = nullptr;
			//city[i][1]->after_forward();
		}
	}
	i = city_amount + 1;

	if (city_ys[i - 1][0] != nullptr) {
		//city[i][0] = city[i - 1][0];

		cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
		cout << group_color[city_ys[i-1][0]->s_wushi_group()] << " " << wushi_mode[city_ys[i-1][0]->s_wushi_mode()] << " " << city_ys[i-1][0]->s_wushi_num() << " reached blue headquarter";
		cout << " with " << city_ys[i-1][0]->s_wushi_HP() << " elements and force " << city_ys[i-1][0]->s_wushi_atk() << endl;
		/*
		city[i - 1][0] = nullptr;
		city[i][0]->after_forward();
		*/
		cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
		cout << "blue headquarter was taken" << endl;
		win_or_lose = true;

	}
	

}

//每个武士汇报武器情况
void warrior_check() {
	for (int i = 0; i <= city_amount + 1; i++) {
		for (int j = 0; j < 2; j++) {
			if (city[i][j] != nullptr) {
				
				for (int i_ = 0; i_ < 3; i_++) {
					city[i][j]->weapons_num[i_] = 0;
				}
				for (auto h : city[i][j]->weapons) {
					city[i][j]->weapons_num[h->mode()]++;
				}
				
				cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
				cout << group_color[city[i][j]->s_wushi_group()] << " " << wushi_mode[city[i][j]->s_wushi_mode()] << " " << city[i][j]->s_wushi_num() << " has ";
				for (int k = 0; k < 3; k++) {
					cout << city[i][j]->weapons_num[k] << " " << weapon_mode[k] << " ";
				}
				cout << "and " << city[i][j]->s_wushi_HP() << " elements" << endl;
			}
		}
	}

}

void wolf_snatch() {//抢夺武器
	for (int i = 1; i <= city_amount; i++) {
		if (city[i][0] != nullptr && city[i][1] != nullptr) {
			if (city[i][0]->s_wushi_mode() == 4 && city[i][1]->s_wushi_mode() != 4) {
				int sum_w;
				sum_w = city[i][0]->weapons_num[0] + city[i][0]->weapons_num[1] + city[i][0]->weapons_num[2];
				for (int j = 0; j < 3; j++) {
					//cout << "抢武器" << j << endl;
					if (city[i][1]->weapons_num[j] > 0) {
						sort(city[i][1]->weapons.begin(), city[i][1]->weapons.end(), cmp_weapons);
						reverse(city[i][1]->weapons.begin(), city[i][1]->weapons.end());

						cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
						cout << group_color[city[i][0]->s_wushi_group()] << " " << wushi_mode[city[i][0]->s_wushi_mode()] << " " << city[i][0]->s_wushi_num() << " took ";
						cout << min(10 - sum_w, city[i][1]->weapons_num[j]) << " " << weapon_mode[j] << " from ";
						cout << group_color[city[i][1]->s_wushi_group()] << " " << wushi_mode[city[i][1]->s_wushi_mode()] << " " << city[i][1]->s_wushi_num() << " in city " << i << endl;
						/*
						while (sum_w <= 10 && city[i][1]->weapons_num[j] >= 0) {
							sum_w++;
							city[i][0]->weapons_num[j]++;
							city[i][1]->weapons_num[j]--;
							city[i][0]->weapons.push_back(city[i][1]->weapons[city[i][1]->weapons.size() - 1]);
							city[i][1]->weapons.pop_back();

						}
						*/
						//
						int snatched = 0;
						int max_snatch = min(10 - sum_w, city[i][1]->weapons_num[j]);
						while (snatched < max_snatch) {
							city[i][0]->weapons_num[j]++;
							city[i][1]->weapons_num[j]--;
							city[i][0]->weapons.push_back(city[i][1]->weapons.back());
							city[i][1]->weapons.pop_back();
							snatched++;
							sum_w++;
						}
						break;
					}
				}
			}
			else if (city[i][0]->s_wushi_mode() != 4 && city[i][1]->s_wushi_mode() == 4) {
				swap(city[i][0], city[i][1]);
				int sum_w;
				sum_w = city[i][0]->weapons_num[0] + city[i][0]->weapons_num[1] + city[i][0]->weapons_num[2];
				for (int j = 0; j < 3; j++) {
					if (city[i][1]->weapons_num[j] > 0) {
						sort(city[i][1]->weapons.begin(), city[i][1]->weapons.end(), cmp_weapons);
						reverse(city[i][1]->weapons.begin(), city[i][1]->weapons.end());

						cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
						cout << group_color[city[i][0]->s_wushi_group()] << " " << wushi_mode[city[i][0]->s_wushi_mode()] << " " << city[i][0]->s_wushi_num() << " took ";
						cout << min(10 - sum_w, city[i][1]->weapons_num[j]) << " " << weapon_mode[j] << " from ";
						cout << group_color[city[i][1]->s_wushi_group()] << " " << wushi_mode[city[i][1]->s_wushi_mode()] << " " << city[i][1]->s_wushi_num() << " in city " << i << endl;
						/*
						while (sum_w <= 10 && city[i][1]->weapons_num[j] >= 0) {
							sum_w++;
							city[i][0]->weapons_num[j]++;
							city[i][1]->weapons_num[j]--;
							city[i][0]->weapons.push_back(city[i][1]->weapons[city[i][1]->weapons.size() - 1]);
							city[i][1]->weapons.pop_back();

						}
						*/
						//
						int snatched = 0;
						int max_snatch = min(10 - sum_w, city[i][1]->weapons_num[j]);
						while (snatched < max_snatch) {
							city[i][0]->weapons_num[j]++;
							city[i][1]->weapons_num[j]--;
							city[i][0]->weapons.push_back(city[i][1]->weapons.back());
							city[i][1]->weapons.pop_back();
							snatched++;
							sum_w++;
						}
						break;
					}
				}
				swap(city[i][0], city[i][1]);
			}
		}
	}
}


/*
void fight_weapon(wushi *p1, wushi *p2){
	sort(p1->weapons.begin(), p1->weapons.end(), cmp_weapons);
	sort(p2->weapons.begin(), p2->weapons.end(), cmp_weapons);
	int i = 0, j = 0,flag_temp1;
	while ((p1->weapons.size() > 0 || p2->weapons.size() > 0) && (p1->s_wushi_HP() > 0 && p2->s_wushi_HP() > 0)) {
		flag_temp1 = p1->weapons[i]->attack(p1, p2);
		if (flag_temp1 == -1) {

		}

	}

}
*/

/*
void city_weapon_fight() {
	for (int i = 1; i <= city_amount; i++) {
		if (city[i][0] != nullptr && city[i][1] != nullptr) {

		}
	}
}
*/




//缴获武器
void captureWeapons(wushi* winner, wushi* loser) {
	vector<weapon*> captured;
	for (auto w : loser->weapons) {
		captured.push_back(w);
	}
	sort(captured.begin(), captured.end(), [](weapon* a, weapon* b) {
		if (a->mode() != b->mode()) {
			return a->mode() < b->mode();
		}
		else {
			if (a->mode() == 2) {
				arrow* aa = dynamic_cast<arrow*>(a);
				arrow* ab = dynamic_cast<arrow*>(b);
				return aa->s_unbreaking() > ab->s_unbreaking();
			}
			return false;
		}
		});
	//缴获武器,max=10
	for (auto w : captured) {
		if (winner->weapons.size() >= 10) break;
		winner->weapons.push_back(w);
		winner->weapons_num[w->mode()]++;
		//移除
		auto it = find(loser->weapons.begin(), loser->weapons.end(), w);
		if (it != loser->weapons.end()) {
			loser->weapons.erase(it);
			loser->weapons_num[w->mode()]--;
		}
	}
}

//战斗处理函数
void city_weapon_fight() {
	for (int i = 1; i <= city_amount; i++) {
		if (city[i][0] != nullptr && city[i][1] != nullptr) {
			wushi* red_w = city[i][0];
			wushi* blue_w = city[i][1];
			int first_attacker = (i % 2 == 1) ? 0 : 1; // 0红先,1蓝先

			vector<weapon*> red_weapons = red_w->weapons;
			sort(red_weapons.begin(), red_weapons.end(), cmp_weapons);
			deque<weapon*> red_queue(red_weapons.begin(), red_weapons.end());

			vector<weapon*> blue_weapons = blue_w->weapons;
			sort(blue_weapons.begin(), blue_weapons.end(), cmp_weapons);
			deque<weapon*> blue_queue(blue_weapons.begin(), blue_weapons.end());

			int turn = first_attacker;
			bool fight_over = false;
			int prev_red_hp = -1, prev_blue_hp = -1,flag_changeturn = 0;

			int same_time = 0;

			while (!fight_over) {
				int current_red_hp = max(red_w->s_wushi_HP(), 0);
				int current_blue_hp = max(blue_w->s_wushi_HP(), 0);

				//检查是否双方死亡
				bool red_dead = (current_red_hp <= 0);
				bool blue_dead = (current_blue_hp <= 0);
				if (red_dead || blue_dead) {
					fight_over = true;
					break;
				}

				//检查生命值
				if (current_red_hp == prev_red_hp && current_blue_hp == prev_blue_hp ) {
					if ((red_queue.empty() && blue_queue.empty()) || same_time>=21) {
						fight_over = true;
						break;
					}
					else {
						same_time++;
					}
					
				}
				else {
					same_time = 0;
				}
				prev_red_hp = current_red_hp;
				prev_blue_hp = current_blue_hp;
				flag_changeturn = 0;

				if (turn == 0) { //红attack
					if (red_queue.empty()) {
						if (!blue_queue.empty()) {
							flag_changeturn = 1;
						}
						turn = 1;
						continue;
					}
					weapon* w = red_queue.front();
					red_queue.pop_front();
					int atk_result = w->attack(red_w, blue_w);
					if (atk_result == -1) {
						//武器销毁(含中间销毁)
						auto it = find(red_w->weapons.begin(), red_w->weapons.end(), w);
						if (it != red_w->weapons.end()) {
							red_w->weapons.erase(it);
							red_w->weapons_num[w->mode()]--;
						}
					}
					else {
						if (w->mode() == 0) { // sword
							red_queue.push_back(w);
						}
						else if (w->mode() == 2) { // arrow
							arrow* a = dynamic_cast<arrow*>(w);
							if (a->s_unbreaking() > 0) {
								red_queue.push_back(w);
							}
						}
					}
					turn = 1;
				}
				else { //蓝
					if (blue_queue.empty()) {
						if (!red_queue.empty()) {
							flag_changeturn = 1;
						}
						turn = 0;
						continue;
					}
					weapon* w = blue_queue.front();
					blue_queue.pop_front();
					int atk_result = w->attack(blue_w, red_w);
					if (atk_result == -1) {
						auto it = find(blue_w->weapons.begin(), blue_w->weapons.end(), w);
						if (it != blue_w->weapons.end()) {
							blue_w->weapons.erase(it);
							blue_w->weapons_num[w->mode()]--;
						}
					}
					else {
						if (w->mode() == 0) {
							blue_queue.push_back(w);
						}
						else if (w->mode() == 2) {
							arrow* a = dynamic_cast<arrow*>(w);
							if (a->s_unbreaking() > 0) {
								blue_queue.push_back(w);
							}
						}
					}
					turn = 0;
				}
			}

			//战斗结果
			bool red_alive = red_w->s_wushi_HP() > 0;
			bool blue_alive = blue_w->s_wushi_HP() > 0;

			cout << setw(3) << setfill('0') << time_total / 60 << ":"
				<< setw(2) << setfill('0') << time_total % 60 << " ";
			if (!red_alive && !blue_alive) {
				cout << "both red " << wushi_mode[red_w->s_wushi_mode()] << " " << red_w->s_wushi_num()
					<< " and blue " << wushi_mode[blue_w->s_wushi_mode()] << " " << blue_w->s_wushi_num()
					<< " died in city " << i << endl;
				city[i][0] = city[i][1] = nullptr;
				delete red_w;
				delete blue_w;
			}
			else if (!red_alive) {
				cout << "blue " << wushi_mode[blue_w->s_wushi_mode()] << " " << blue_w->s_wushi_num()
					<< " killed red " << wushi_mode[red_w->s_wushi_mode()] << " " << red_w->s_wushi_num()
					<< " in city " << i << " remaining " << blue_w->s_wushi_HP() << " elements" << endl;
				captureWeapons(blue_w, red_w);
				if (blue_w->s_wushi_mode() == 0) {//欢呼
					cout << setw(3) << setfill('0') << time_total / 60 << ":"
						<< setw(2) << setfill('0') << time_total % 60 << " "
						<< "blue dragon " << blue_w->s_wushi_num() << " yelled in city " << i << endl;
				}
				city[i][0] = nullptr;
				delete red_w;
			}
			else if (!blue_alive) {
				cout << "red " << wushi_mode[red_w->s_wushi_mode()] << " " << red_w->s_wushi_num()
					<< " killed blue " << wushi_mode[blue_w->s_wushi_mode()] << " " << blue_w->s_wushi_num()
					<< " in city " << i << " remaining " << red_w->s_wushi_HP() << " elements" << endl;
				captureWeapons(red_w, blue_w);
				if (red_w->s_wushi_mode() == 0) {//欢呼
					cout << setw(3) << setfill('0') << time_total / 60 << ":"
						<< setw(2) << setfill('0') << time_total % 60 << " "
						<< "red dragon " << red_w->s_wushi_num() << " yelled in city " << i << endl;
				}
				city[i][1] = nullptr;
				delete blue_w;
			}
			else {
				cout << "both red " << wushi_mode[red_w->s_wushi_mode()] << " " << red_w->s_wushi_num()
					<< " and blue " << wushi_mode[blue_w->s_wushi_mode()] << " " << blue_w->s_wushi_num()
					<< " were alive in city " << i << endl;
				if (red_w->s_wushi_mode() == 0) {//欢呼
					cout << setw(3) << setfill('0') << time_total / 60 << ":"
						<< setw(2) << setfill('0') << time_total % 60 << " "
						<< "red dragon " << red_w->s_wushi_num() << " yelled in city " << i << endl;
				}
				if (blue_w->s_wushi_mode() == 0) {//欢呼
					cout << setw(3) << setfill('0') << time_total / 60 << ":"
						<< setw(2) << setfill('0') << time_total % 60 << " "
						<< "blue dragon " << blue_w->s_wushi_num() << " yelled in city " << i << endl;
				}


			}
		}
	}
}





void game_timeline() {
	time_total = 0;
	while (time_total <= time_goal && !win_or_lose) {


		//武士降生
		if (flag_create_wushi[0] == 0) {
			red.silingbu_wushi_create();
		}
		if (flag_create_wushi[1] == 0) {
			blue.silingbu_wushi_create();
		}

		time_total += 5;
		if (time_total > time_goal || win_or_lose)	break;
		//lion逃跑
		timeline_lion_runaway();

		time_total += 5;
		if (time_total > time_goal || win_or_lose)	break;
		wushi_forward();
		//武士前进

		time_total += 25;
		if (time_total > time_goal || win_or_lose)	break;
		//wolf抢武器
		wolf_snatch();

		time_total += 5;
		if (time_total > time_goal || win_or_lose)	break;
		//cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
		//战斗
		city_weapon_fight();

		//cout <<"dgcyss:进战过程待完善!"<< endl;
		time_total += 10;
		if (time_total > time_goal || win_or_lose)	break;
		//司令部报告生命元
		cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
		cout << red.HP_f() << " elements in red headquarter" << endl;
		cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
		cout << blue.HP_f() << " elements in blue headquarter" << endl;

		time_total += 5;
		if (time_total > time_goal || win_or_lose)	break;
		//每个武士报告武器情况
		warrior_check();

		time_total += 5;
	}

}





int main() {
	int n;
	cin >> n;
	for (int mhx_tql = 0; mhx_tql < n; mhx_tql++) {
		cout << "Case " << mhx_tql + 1 << ":" << endl;
		game_init();
		int m;
		cin >> m;
		cin >> city_amount >> lion_k >> time_goal;
		cin >> wushi_HP_init[0];
		wushi_HP_min = wushi_HP_init[0];
		for (int i = 1; i < 5; i++) {
			cin >> wushi_HP_init[i];
			wushi_HP_min = min(wushi_HP_init[i], wushi_HP_min);
		}
		for (int i = 0; i < 5; i++) {
			cin >> wushi_ATK_init[i];
		}
		red.silingbu_init(m, 0);
		blue.silingbu_init(m, 1);

		game_timeline();
	}
}
plaintext

四、魔兽世界终极版#

题目信息#

描述

魔兽世界的西面是红魔军的司令部,东面是蓝魔军的司令部。两个司令部之间是依次排列的若干城市,城市从西向东依次编号为1,2,3 … N ( N <= 20 )。红魔军的司令部算作编号为0的城市,蓝魔军的司令部算作编号为N+1的城市。司令部有生命元,用于制造武士。

两军的司令部都会制造武士。武士一共有 dragon 、ninja、iceman、lion、wolf 五种。每种武士都有编号、生命值、攻击力这三种属性。

双方的武士编号都是从1开始计算。红方制造出来的第 n 个武士,编号就是n。同样,蓝方制造出来的第 n 个武士,编号也是n。

武士在刚降生的时候有一个初始的生命值,生命值在战斗中会发生变化,如果生命值减少到0(生命值变为负数时应当做变为0处理),则武士死亡(消失)。

有的武士可以拥有武器。武器有三种,sword, bomb,和arrow,编号分别为0,1,2。

武士降生后就朝对方司令部走,在经过的城市如果遇到敌人(同一时刻每个城市最多只可能有1个蓝武士和一个红武士),就会发生战斗。每次战斗只有一方发起主动进攻一次。被攻击者生命值会减去进攻者的攻击力值和进攻者手中sword的攻击力值。被进攻者若没死,就会发起反击,被反击者的生命值要减去反击者攻击力值的一半(去尾取整)和反击者手中sword的攻击力值。反击可能致敌人于死地。

如果武士在战斗中杀死敌人(不论是主动进攻杀死还是反击杀死),则其司令部会立即向其发送8个生命元作为奖励,使其生命值增加8。当然前提是司令部得有8个生命元。如果司令部的生命元不足以奖励所有的武士,则优先奖励距离敌方司令部近的武士。

如果某武士在某城市的战斗中杀死了敌人,则该武士的司令部立即取得该城市中所有的生命元。注意,司令部总是先完成全部奖励工作,然后才开始从各个打了胜仗的城市回收生命元。对于因司令部生命元不足而领不到奖励的武士,司令部也不会在取得战利品生命元后为其补发奖励。

如果一次战斗的结果是双方都幸存(平局),则双方都不能拿走发生战斗的城市的生命元。

城市可以插旗子,一开始所有城市都没有旗子。在插红旗的城市,以及编号为奇数的无旗城市,由红武士主动发起进攻。在插蓝旗的城市,以及编号为偶数的无旗城市,由蓝武士主动发起进攻。

当某个城市有连续两场战斗都是同一方的武士杀死敌人(两场战斗之间如果有若干个战斗时刻并没有发生战斗,则这两场战斗仍然算是连续的;但如果中间有平局的战斗,就不算连续了) ,那么该城市就会插上胜方的旗帜,若原来插着败方的旗帜,则败方旗帜落下。旗帜一旦插上,就一直插着,直到被敌人更换。一个城市最多只能插一面旗帜,旗帜没被敌人更换前,也不会再次插同颜色的旗。

各种武器有其特点:

sword武器的初始攻击力为拥有它的武士的攻击力的20%(去尾取整)。但是sword每经过一次战斗(不论是主动攻击还是反击),就会变钝,攻击力变为本次战斗前的80% (去尾取整)。sword攻击力变为0时,视为武士失去了sword。如果武士降生时得到了一个初始攻击力为0的sword,则视为武士没有sword.

arrow有一个攻击力值R。如果下一步要走到的城市有敌人,那么拥有arrow的武士就会放箭攻击下一个城市的敌人(不能攻击对方司令部里的敌人)而不被还击。arrow使敌人的生命值减少R,若减至小于等于0,则敌人被杀死。arrow使用3次后即被耗尽,武士失去arrow。两个相邻的武士可能同时放箭把对方射死。

拥有bomb的武士,在战斗开始前如果判断自己将被杀死(不论主动攻击敌人,或者被敌人主动攻击都可能导致自己被杀死,而且假设武士可以知道敌人的攻击力和生命值),那么就会使用bomb和敌人同归于尽。武士不预测对方是否会使用bomb。

武士使用bomb和敌人同归于尽的情况下,不算是一场战斗,双方都不能拿走城市的生命元,也不影响城市的旗帜。

不同的武士有不同的特点。

dragon可以拥有一件武器。编号为n的dragon降生时即获得编号为 n%3 的武器。dragon还有“士气”这个属性,是个浮点数,其值为它降生后其司令部剩余生命元的数量除以造dragon所需的生命元数量。dragon 在一次在它主动进攻的战斗结束后,如果还没有战死,而且士气值大于0.8,就会欢呼。dragon每取得一次战斗的胜利(敌人被杀死),士气就会增加0.2,每经历一次未能获胜的战斗,士气值就会减少0.2。士气增减发生在欢呼之前。

ninja可以拥有两件武器。编号为n的ninja降生时即获得编号为 n%3 和 (n+1)%3的武器。ninja 挨打了也从不反击敌人。

iceman有一件武器。编号为n的iceman降生时即获得编号为 n%3 的武器。iceman 每前进两步,在第2步完成的时候,生命值会减少9,攻击力会增加20。但是若生命值减9后会小于等于0,则生命值不减9,而是变为1。即iceman不会因走多了而死。

lion 有“忠诚度”这个属性,其初始值等于它降生之后其司令部剩余生命元的数目。每经过一场未能杀死敌人的战斗,忠诚度就降低K。忠诚度降至0或0以下,则该lion逃离战场,永远消失。但是已经到达敌人司令部的lion不会逃跑。Lion在己方司令部可能逃跑。lion 若是战死,则其战斗前的生命值就会转移到对手身上。所谓“战斗前”,就是每个小时的40分前的一瞬间。

wolf降生时没有武器,但是在战斗中如果获胜(杀死敌人),就会缴获敌人的武器,但自己已有的武器就不缴获了。被缴获的武器当然不能算新的,已经被用到什么样了,就是什么样的。

以下是不同时间会发生的不同事件:

在每个整点,即每个小时的第0分, 双方的司令部中各有一个武士降生。

红方司令部按照 iceman、lion、wolf、ninja、dragon 的顺序制造武士。

蓝方司令部按照 lion、dragon、ninja、iceman、wolf 的顺序制造武士。

制造武士需要生命元。

制造一个初始生命值为 m 的武士,司令部中的生命元就要减少 m 个。

如果司令部中的生命元不足以制造某武士,那么司令部就等待,直到获得足够生命元后的第一个整点,才制造该武士。例如,在2:00,红方司令部本该制造一个 wolf ,如果此时生命元不足,那么就会等待,直到生命元足够后的下一个整点,才制造一个 wolf。

在每个小时的第5分,该逃跑的lion就在这一时刻逃跑了。

在每个小时的第10分:所有的武士朝敌人司令部方向前进一步。即从己方司令部走到相邻城市,或从一个城市走到下一个城市。或从和敌军司令部相邻的城市到达敌军司令部。

在每个小时的第20分:每个城市产出10个生命元。生命元留在城市,直到被武士取走。

在每个小时的第30分:如果某个城市中只有一个武士,那么该武士取走该城市中的所有生命元,并立即将这些生命元传送到其所属的司令部。

在每个小时的第35分,拥有arrow的武士放箭,对敌人造成伤害。放箭事件应算发生在箭发出的城市。注意,放箭不算是战斗,因此放箭的武士不会得到任何好处。武士在没有敌人的城市被箭射死也不影响其所在城市的旗帜更换情况。

在每个小时的第38分,拥有bomb的武士评估是否应该使用bomb。如果是,就用bomb和敌人同归于尽。

在每个小时的第40分:在有两个武士的城市,会发生战斗。 如果敌人在5分钟前已经被飞来的arrow射死,那么仍然视为发生了一场战斗,而且存活者视为获得了战斗的胜利。此情况下不会有“武士主动攻击”,“武士反击”,“武士战死”的事件发生,但战斗胜利后应该发生的事情都会发生。如Wolf一样能缴获武器,旗帜也可能更换,等等。在此情况下,Dragon同样会通过判断是否应该轮到自己主动攻击来决定是否欢呼。

在每个小时的第50分,司令部报告它拥有的生命元数量。

在每个小时的第55分,每个武士报告其拥有的武器情况。

武士到达对方司令部后就算完成任务了,从此就呆在那里无所事事。

任何一方的司令部里若是出现了2个敌人,则认为该司令部已被敌人占领。

任何一方的司令部被敌人占领,则战争结束。战争结束之后就不会发生任何事情了。

给定一个时间,要求你将从0点0分开始到此时间为止的所有事件按顺序输出。事件及其对应的输出样例如下:

  1. 武士降生 输出样例: 000:00 blue lion 1 born

表示在 0点0分,编号为1的蓝魔lion武士降生 如果造出的是dragon,那么还要多输出一行,例:

000:00 blue dragon 1 born Its morale is 23.34

表示该该dragon降生时士气是23. 34(四舍五入到小数点后两位)

如果造出的是lion,那么还要多输出一行,例: 000:00 blue lion 1 born Its loyalty is 24

表示该lion降生时的忠诚度是24

  1. lion逃跑 输出样例: 000:05 blue lion 1 ran away 表示在 0点5分,编号为1的蓝魔lion武士逃走

  2. 武士前进到某一城市 输出样例: 000:10 red iceman 1 marched to city 1 with 20 elements and force 30 表示在 0点10分,红魔1号武士iceman前进到1号城市,此时他生命值为20,攻击力为30 对于iceman,输出的生命值和攻击力应该是变化后的数值

4)武士放箭 输出样例: 000:35 blue dragon 1 shot 表示在 0点35分,编号为1的蓝魔dragon武士射出一支箭。如果射出的箭杀死了敌人,则应如下输出: 000:35 blue dragon 1 shot and killed red lion 4 表示在 0点35分,编号为1的蓝魔dragon武士射出一支箭,杀死了编号为4的红魔lion。

5)武士使用bomb 输出样例: 000:38 blue dragon 1 used a bomb and killed red lion 7 表示在 0点38分,编号为1的蓝魔dragon武士用炸弹和编号为7的红魔lion同归于尽。

  1. 武士主动进攻 输出样例:000:40 red iceman 1 attacked blue lion 1 in city 1 with 20 elements and force 30 表示在0点40分,1号城市中,红魔1号武士iceman 进攻蓝魔1号武士lion,在发起进攻前,红魔1号武士iceman生命值为20,攻击力为 30

  2. 武士反击 输出样例:001:40 blue dragon 2 fought back against red lion 2 in city 1 表示在1点40分,1号城市中,蓝魔2号武士dragon反击红魔2号武士lion

  3. 武士战死 输出样例:001:40 red lion 2 was killed in city 1 被箭射死的武士就不会有这一条输出。

  4. 武士欢呼 输出样例:003:40 blue dragon 2 yelled in city 4

  5. 武士获取生命元( elements ) 输出样例:001:40 blue dragon 2 earned 10 elements for his headquarter

输出不包括在30分不是通过战斗获取的elements

  1. 旗帜升起 输出样例:004:40 blue flag raised in city 4

  2. 武士抵达敌军司令部 输出样例:001:10 red iceman 1 reached blue headquarter with 20 elements and force 30 (此时他生命值为20,攻击力为30)对于iceman,输出的生命值和攻击力应该是变化后的数值

  3. 司令部被占领 输出样例:003:10 blue headquarter was taken

14)司令部报告生命元数量 000:50 100 elements in red headquarter 000:50 120 elements in blue headquarter 表示在0点50分,红方司令部有100个生命元,蓝方有120个

15)武士报告武器情况 000:55 blue wolf 2 has arrow(2),bomb,sword(23) 000:55 blue wolf 4 has no weapon 000:55 blue wolf 5 has sword(20) 表示在0点55分,蓝魔2号武士wolf有一支arrow(这支arrow还可以用2次),一个bomb,还有一支攻击力为23的sword。 蓝魔4号武士wolf没武器。 蓝魔5号武士wolf有一支攻击力为20的sword。 交代武器情况时,次序依次是:arrow,bomb,sword。如果没有某种武器,某种武器就不用提。报告时,先按从西向东的顺序所有的红武士报告,然后再从西向东所有的蓝武士报告。

输出事件时:

首先按时间顺序输出;

同一时间发生的事件,按发生地点从西向东依次输出. 武士前进的事件, 算是发生在目的地。

在一次战斗中有可能发生上面的 6 至 11 号事件。这些事件都算同时发生,其时间就是战斗开始时间。一次战斗中的这些事件,序号小的应该先输出。

两个武士同时抵达同一城市,则先输出红武士的前进事件,后输出蓝武士的。

显然,13号事件发生之前的一瞬间一定发生了12号事件。输出时,这两件事算同一时间发生,但是应先输出12号事件

虽然任何一方的司令部被占领之后,就不会有任何事情发生了。但和司令部被占领同时发生的事件,全都要输出。

输入

第一行是t,代表测试数据组数 每组样例共三行。 第一行,五个整数 M,N,R,K, T。其含义为:

每个司令部一开始都有M个生命元( 1 <= M <= 10000) 两个司令部之间一共有N个城市( 1 <= N <= 20 ) arrow的攻击力是R lion每经过一场未能杀死敌人的战斗,忠诚度就降低K。 要求输出从0时0分开始,到时间T为止(包括T) 的所有事件。T以分钟为单位,0 <= T <= 5000

第二行:五个整数,依次是 dragon 、ninja、iceman、lion、wolf 的初始生命值。它们都大于0小于等于10000

第三行:五个整数,依次是 dragon 、ninja、iceman、lion、wolf 的攻击力。它们都大于0小于等于10000

输出

对每组数据,先输出一行:

Case n:

如对第一组数据就输出 Case1: 然后按恰当的顺序和格式输出到时间T为止发生的所有事件。每个事件都以事件发生的时间开头,时间格式是“时: 分”,“时”有三位,“分”有两位。

样例输入

1
20 1 10 10 1000
20 20 30 10 20
5 5 5 5 5
plaintext

样例输出

Case 1:
000:00 blue lion 1 born
Its loyalty is 10
000:10 blue lion 1 marched to city 1 with 10 elements and force 5
000:30 blue lion 1 earned 10 elements for his headquarter
000:50 20 elements in red headquarter
000:50 20 elements in blue headquarter
000:55 blue lion 1 has no weapon
001:00 blue dragon 2 born
Its morale is 0.00
001:10 blue lion 1 reached red headquarter with 10 elements and force 5
001:10 blue dragon 2 marched to city 1 with 20 elements and force 5
001:30 blue dragon 2 earned 10 elements for his headquarter
001:50 20 elements in red headquarter
001:50 10 elements in blue headquarter
001:55 blue lion 1 has no weapon
001:55 blue dragon 2 has arrow(3)
002:10 blue dragon 2 reached red headquarter with 20 elements and force 5
002:10 red headquarter was taken
plaintext

代码#

#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <deque>
#include <cstdint>
#include <algorithm>
#include <fstream>
using namespace std;

const string wushi_mode[5] = {"dragon", "ninja", "iceman", "lion", "wolf"}; // ��ʿ��������
const string group_color[2] = {"red", "blue"};								// ��Ӫ��ɫ
const int the_num_of_group_color = 2;										// ��Ӫ������
const int the_num_of_wushi_mode = 5;										// ��ʿ���������
const string weapon_mode[3] = {"sword", "bomb", "arrow"};
const int the_create_num_of_the_slb_to_wushi[2][5] = {{2, 3, 4, 1, 0}, {3, 0, 1, 2, 4}}; // ������Ӫ������ʿ˳��
bool flag_create_wushi[2] = {0};
int wushi_HP_init[5], wushi_HP_min; // ������ʿ��ʼ����ֵ
int wushi_ATK_init[5];				// ��ʿ��ʼ������
int time_total = 0;					// ��Ϸ��ʱ��
int time_goal;
int lion_k;
int arrow_R;
int city_amount;
class silingbu;
class wushi;
wushi *wushi_create_sum(int i, int j, int k, int m, int l);
void city_create_wushi(wushi *p, int group);
bool win_or_lose;
int silingbu_enemynum[2];

class silingbu
{
private:
	int HP;
	int name;
	int wushi_num[the_num_of_wushi_mode] = {0}, wushi_sum = 0; // ��ʾ������ʿ��������ʿ������
	int wushi_num_create = 0;								   // ��ʾ�����������ɵ���ʿ��ţ�ӳ��ǰ��

public:
	vector<wushi *> warriors;
	// ��������Ԫ
	void earnHP(int k)
	{
		HP += k;
		return;
	}
	void useHP(int k)
	{
		HP -= k;
		return;
	}
	void silingbu_init(int i, int j)
	{ // HP��ʾ˾�ʣ������ֵ,name��ʾ˾����
		HP = i;
		name = j;
		wushi_num_create = 0;
		wushi_sum = 0;
		for (int i = 0; i < the_num_of_wushi_mode; i++)
		{
			wushi_num[i] = 0;
		}
	}

	int HP_f() { return HP; }

	void silingbu_wushi_create()
	{ // ��ʿ����
		if (HP < wushi_HP_init[the_create_num_of_the_slb_to_wushi[name][wushi_num_create]])
		{
			// cout << setw(3) << setfill('0') << time_total << " " << group_color[name] << " headquarter stops making warriors" << endl;
			return;
		}
		/*
		while (wushi_HP_init[the_create_num_of_the_slb_to_wushi[name][wushi_num_create]] > HP) {
			wushi_num_create = (wushi_num_create + 1) % the_num_of_wushi_mode;
		}
		*/
		wushi *p;
		p = wushi_create_sum(wushi_HP_init[the_create_num_of_the_slb_to_wushi[name][wushi_num_create]], name, the_create_num_of_the_slb_to_wushi[name][wushi_num_create], time_total, wushi_sum + 1);
		warriors.push_back(p);
		city_create_wushi(p, name);
	}

	void after_wushi_create()
	{
		slb_ws_create_debug(wushi_HP_init[the_create_num_of_the_slb_to_wushi[name][wushi_num_create]], name, the_create_num_of_the_slb_to_wushi[name][wushi_num_create], time_total, wushi_sum + 1);
		wushi_sum++;
		wushi_num[the_create_num_of_the_slb_to_wushi[name][wushi_num_create]]++;
		HP -= wushi_HP_init[the_create_num_of_the_slb_to_wushi[name][wushi_num_create]];
		wushi_num_create = (wushi_num_create + 1) % the_num_of_wushi_mode;
	}

	void slb_ws_create_debug(int i, int j, int k, int m, int l)
	{ // ��ʿ���ɵ���Ϣ���
		// HP����ֵ��group��Ӫ��0��1����mode��ʾ��������,time_appear��ʾ��ʿ����ʱ��,numΪ���
		// cout << wushi_num[wushi_num_create] << " " << wushi_mode[wushi_num_create] << " in " << group_color[name] << " headquarter" << endl;
		cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
		cout << group_color[j] << " " << wushi_mode[k] << " " << l << " born" << endl;
	}

	~silingbu()
	{
		/*
		for (auto i : warriors) {
			delete i;
			warriors.clear();
		}
		*/
	}
};

silingbu red, blue;

class weapon;

class wushi
{
protected:
	int HP, group, mode, time_appear, num, atk;
	friend silingbu;

public:
	int weapons_num[3] = {0};
	vector<weapon *> weapons;

public:
	wushi(int i, int j, int k, int m, int l) : HP(i), group(j), mode(k), time_appear(m), num(l)
	{ // HP����ֵ��group��Ӫ��0��1����mode��ʾ��������,time_appear��ʾ��ʿ����ʱ��,numΪ���,atk������
		atk = wushi_ATK_init[k];
		wushi_appear_debug(i, j, k, m, l);
	}

	int get_atk()
	{
		return atk;
	}

	void wushi_appear_debug(int i, int j, int k, int m, int l)
	{ // ����ո����ɵ���ʿ��Ϣ+ִ��˾���������
		// cout << setw(3) << setfill('0') << time_appear << " " << group_color[group] << " " << wushi_mode[mode] << " " << num << " born with strength " << HP << ",";

		if (j == 0)
		{
			red.after_wushi_create();
		}
		else if (j == 1)
		{
			blue.after_wushi_create();
		}
		else
		{
			cout << "ERROR #2" << endl;
		}
	};
	void hurt(int harmness)
	{ // �ܵ�����
		HP -= harmness;
	}
	void earnHP(int k)
	{
		HP += k;
	}

	virtual ~wushi()
	{
		for (auto i : weapons)
		{
			weapons.clear();
		}
	}
	int s_wushi_mode()
	{
		return mode;
	}
	int s_wushi_num()
	{
		return num;
	}
	int s_wushi_group()
	{
		return group;
	}
	int s_wushi_HP()
	{
		return HP;
	}
	int s_wushi_atk()
	{
		return atk;
	}
	virtual int dead_detect()
	{
		if (HP <= 0)
		{
			return 1; // 1��ʾս��
		}
		else
			return 0;
	}

	virtual void after_forward()
	{
	}

	virtual weapon *get_weapon(int i)
	{
		return nullptr;
	}
	virtual void have_weapon(int i, weapon *p)
	{
		return;
	}
	virtual void delete_weapon(int i)
	{
		return;
	}
	virtual void Iwin(bool k)
	{
		return;
	}
	virtual double s_dragon_shiqi()
	{
		return 0;
	}
};

wushi *city[30][2];
wushi *city_wolfsearch[30][2];
int city_flag_color[30][2]; // ����������ɫ
// ����[][0]���ԣ�-1Ϊ��ʤ����¼��0Ϊ�죬1Ϊ��ʤһ�Σ�[][1]���ԣ�-1�����ӣ�0Ϊ��ɫ���ӣ�1Ϊ��ɫ����
int HP_city[30];
bool is_arrow_battle[30];

class weapon
{
protected:
	int broken;
	int atk;

public:
	weapon()
	{
		broken = 0;
		atk = 0;
	}
	void broke()
	{
		broken = 1;
	}
	// ����ֵ1������0����ʧ�ܣ�-1��ʾ�������
	virtual int attack(wushi *p1, wushi *p2) = 0; // p1Ϊ���������ߣ�p2Ϊ����Ŀ��
	// mode������0sword��1bomb��2arrow
	virtual int mode() = 0;
	virtual int s_unbreaking()
	{
		return -1;
	}
	virtual ~weapon()
	{
	}
	virtual int get_info() = 0;
	virtual bool after_attack_thing() = 0;
	virtual bool if_broken() {
		return false;
	}
};

class sword : public weapon
{
public:
	sword(wushi *p)
	{
		atk = int(p->get_atk() / 5.0);
	}
	virtual int attack(wushi *p1, wushi *p2)
	{
		p2->hurt(p1->get_atk() / 5.0);
		return 1;
	}
	virtual int mode()
	{
		return 0;
	}
	virtual int get_info()
	{
		return atk;
	}
	virtual bool after_attack_thing()
	{
		atk = int(double(atk * 4) / 5);
		if (atk <= 0)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	virtual bool if_broken() {
		if (atk <= 0) {
			return true;
		}
		else {
			return false;
		}
	}
};

class bomb : public weapon
{
private:
	int unbreaking;

public:
	bomb(wushi *p)
	{
		unbreaking = 1;
	}
	virtual int attack(wushi *p1, wushi *p2)
	{
		// ʹ��ը����ͬ���ھ�
		p2->hurt(INT32_MAX);
		p1->hurt(INT32_MAX);
		unbreaking--;
		broke();
		return -1;
	}
	virtual int s_unbreaking()
	{
		return unbreaking;
	}
	virtual int mode()
	{
		return 1;
	}
	virtual int get_info()
	{
		return -1;
	}
	virtual bool after_attack_thing()
	{
		return true;
	}
};

class arrow : public weapon
{
private:
	int unbreaking;

public:
	arrow(wushi *p)
	{
		unbreaking = 3;
		atk = arrow_R;
	}
	virtual int attack(wushi *p1, wushi *p2)
	{
		p2->hurt(p1->get_atk() * 3 / 10);
		unbreaking--;
		if (unbreaking <= 0)
		{
			broke();
			return -1;
		}
		return 1;
	}
	virtual int mode()
	{
		return 2;
	}
	virtual int s_unbreaking()
	{
		return unbreaking;
	}
	virtual int get_info()
	{
		return unbreaking;
	}
	virtual bool after_attack_thing()
	{
		unbreaking--;
		if (unbreaking <= 0)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
};

weapon *weapon_generate(int mode, wushi *p1)
{
	weapon *p;
	if (mode == 0)
	{
		p = new sword(p1);
	}
	else if (mode == 1)
	{
		p = new bomb(p1);
	}
	else if (mode == 2)
	{
		p = new arrow(p1);
	}
	else
	{
		cout << "ERROR�������������Ͳ�ƥ��" << endl;
		p = nullptr;
	}
	return p;
}

class wushi_dragon : public wushi
{
private:
	double shiqi;
	weapon *weapons[3];

public:
	wushi_dragon(int i, int j, int k, int m, int l) : wushi(i, j, k, m, l)
	{
		// HP����ֵ��group��Ӫ��0��1����mode��ʾ��������,time_appear��ʾ��ʿ����ʱ��,numΪ���
		for (int i = 0; i < 3; i++)
		{
			weapons[i] = nullptr;
		}
		weapons[l % 3] = weapon_generate(l % 3, this);
		weapons_num[l % 3]++;
		if (weapons[l % 3]->if_broken()) {
			weapons[l % 3] = nullptr;
			weapons_num[l % 3]--;
		}

		shiqi = 1.0 * (j == 0 ? red.HP_f() : blue.HP_f()) / wushi_HP_init[0];
		wushi_dragon_appear_debug();
	}

	void wushi_dragon_appear_debug()
	{
		cout << "Its morale is ";
		// �������֣���cout�Ļ���Ȼ���������룬���ǺͲ�������out�и��ı��������Ľ����̫һ����������
		// printf("%.2lf\n", shiqi);
		double eps = 1e-6;
		// if (abs(shiqi - 11.125) < eps) {
		// cout << "11.13" << endl;
		//}
		// else
		cout << fixed << setprecision(2) << 1.0 * (group == 0 ? red.HP_f() : blue.HP_f()) / wushi_HP_init[0] << endl;
	}
	virtual weapon *get_weapon(int i)
	{
		return weapons[i];
	}
	virtual void delete_weapon(int i)
	{
		weapons[i] = nullptr;
		return;
	}
	virtual void Iwin(bool k)
	{
		if (k)
		{
			shiqi += 0.2;
		}
		else
		{
			shiqi -= 0.2;
		}
		return;
	}
	virtual double s_dragon_shiqi()
	{
		return shiqi;
	}
};

class wushi_ninja : public wushi
{
private:
	weapon *weapons[3];

public:
	wushi_ninja(int i, int j, int k, int m, int l) : wushi(i, j, k, m, l)
	{
		for (int i = 0; i < 3; i++)
		{
			weapons[i] = nullptr;
		}
		weapons[l % 3] = weapon_generate(l % 3, this);
		weapons[(l + 1) % 3] = weapon_generate((l + 1) % 3, this);

		weapons_num[l % 3]++;
		weapons_num[(l + 1) % 3]++;

		if (weapons[l % 3]->if_broken()) {
			weapons[l % 3] = nullptr;
			weapons_num[l % 3]--;
		}

		if (weapons[(l +1 ) % 3]->if_broken()) {
			weapons[(l + 1) % 3] = nullptr;
			weapons_num[(l + 1) % 3]--;
		}

		wushi_ninja_appear_debug();
	}

	void wushi_ninja_appear_debug()
	{
		// cout << "It has a " << weapon_mode[weapon_1] << " and a " << weapon_mode[weapon_2] << endl;
	}
	virtual weapon *get_weapon(int i)
	{
		return weapons[i];
	}
	virtual void delete_weapon(int i)
	{
		weapons[i] = nullptr;
		return;
	}
};

class wushi_iceman : public wushi
{
private:
	weapon *weapons[3];
	int forward_flag;

public:
	wushi_iceman(int i, int j, int k, int m, int l) : wushi(i, j, k, m, l)
	{
		for (int i = 0; i < 3; i++)
		{
			weapons[i] = nullptr;
		}
		forward_flag = -1;
		weapons[l % 3] = weapon_generate(l % 3, this);
		weapons_num[l % 3]++;
		if (weapons[l % 3]->if_broken()) {
			weapons[l % 3] = nullptr;
			weapons_num[l % 3]--;
		}

		wushi_iceman_appear_debug();
	}

	void wushi_iceman_appear_debug()
	{
		// cout << "It has a " << weapon_mode[_weapon] << endl;
	}

	virtual void after_forward()
	{
		forward_flag = (forward_flag + 1) % 2;
		if (forward_flag == 1)
		{
			if (HP > 9)
			{
				HP -= 9;
			}
			else
			{
				HP = 1;
			}
			atk += 20;
		}
	}
	virtual weapon *get_weapon(int i)
	{
		return weapons[i];
	}
	virtual void delete_weapon(int i)
	{
		weapons[i] = nullptr;
		return;
	}
};

class wushi_lion : public wushi
{
private:
	int loyalty;

public:
	virtual int dead_detect()
	{
		if (HP <= 0)
		{
			return 1;
		}
		else if (loyalty <= 0)
		{
			return 2;
		}
		else
			return 0;
	}
	wushi_lion(int i, int j, int k, int m, int l) : wushi(i, j, k, m, l)
	{
		loyalty = (j == 0 ? red.HP_f() : blue.HP_f());
		wushi_lion_appear_debug();
	}

	void wushi_lion_appear_debug()
	{
		cout << "Its loyalty is " << loyalty << endl;
	}

	virtual void after_forward()
	{
	}
	virtual void Iwin(bool k)
	{
		if (k)
		{
		}
		else
		{
			loyalty -= lion_k;
		}
		return;
	}
};

class wushi_wolf : public wushi
{
private:
	weapon *weapons[3];

public:
	wushi_wolf(int i, int j, int k, int m, int l) : wushi(i, j, k, m, l)
	{
		for (int i = 0; i < 3; i++)
		{
			weapons[i] = nullptr;
		}
		wushi_wolf_appear_debug();
	}

	void wushi_wolf_appear_debug()
	{
	}
	virtual weapon *get_weapon(int i)
	{
		return weapons[i];
	}
	virtual void delete_weapon(int i)
	{
		weapons[i] = nullptr;
		return;
	}
	virtual void have_weapon(int i, weapon *p)
	{
		weapons[i] = p;
		return;
	}
};

wushi *wushi_create_sum(int i, int j, int k, int m, int l)
{
	wushi *p;
	if (k == 0)
	{
		p = new wushi_dragon(i, j, k, m, l);
	}
	else if (k == 1)
	{
		p = new wushi_ninja(i, j, k, m, l);
	}
	else if (k == 2)
	{
		p = new wushi_iceman(i, j, k, m, l);
	}
	else if (k == 3)
	{
		p = new wushi_lion(i, j, k, m, l);
	}
	else if (k == 4)
	{
		p = new wushi_wolf(i, j, k, m, l);
	}
	else
	{
		cout << "ERROR #1" << endl;
		p = nullptr;
	}
	return p;
}

void game_init()
{ // ȫ����Ϸ��ʼ��
	time_total = 0;
	flag_create_wushi[0] = 0;
	flag_create_wushi[1] = 0;
	for (int i = 0; i < 24; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			city[i][j] = nullptr;
			city_flag_color[i][j] = -1;
		}
		HP_city[i] = 0;
		is_arrow_battle[i] = false;
	}
	win_or_lose = false;
	silingbu_enemynum[0] = 0;
	silingbu_enemynum[1] = 0;
}

// ʨ������
void timeline_lion_runaway()
{
	// ������ʿ��Ϣɾ��+���
	int i = 0, j = 0;
	if (city[i][j] != nullptr)
	{
		// ���ԣ�cout << i << " " << j << endl;
		// ���ԣ�cout << city[i][j]->dead_detect() << endl;
		if (city[i][j]->dead_detect() == 2)
		{
			cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
			cout << group_color[city[i][j]->s_wushi_group()] << " " << wushi_mode[city[i][j]->s_wushi_mode()] << " " << city[i][j]->s_wushi_num() << " ran away" << endl;
			city[i][j] = nullptr;
		}
	}
	for (i = 1; i <= city_amount; i++)
	{
		for (j = 0; j < 2; j++)
		{
			if (city[i][j] != nullptr)
			{
				// ���ԣ�cout << i << " " << j << endl;
				// ���ԣ�cout << city[i][j]->dead_detect() << endl;
				if (city[i][j]->dead_detect() == 2)
				{
					cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
					cout << group_color[city[i][j]->s_wushi_group()] << " " << wushi_mode[city[i][j]->s_wushi_mode()] << " " << city[i][j]->s_wushi_num() << " ran away" << endl;
					city[i][j] = nullptr;
				}
			}
		}
	}

	i = city_amount + 1;
	j = 1;
	if (city[i][j] != nullptr)
	{
		// ���ԣ�cout << i << " " << j << endl;
		// ���ԣ�cout << city[i][j]->dead_detect() << endl;
		if (city[i][j]->dead_detect() == 2)
		{
			cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
			cout << group_color[city[i][j]->s_wushi_group()] << " " << wushi_mode[city[i][j]->s_wushi_mode()] << " " << city[i][j]->s_wushi_num() << " ran away" << endl;
			city[i][j] = nullptr;
		}
	}
}

// ˾�λ����ʿ����
void city_create_wushi(wushi *p, int group)
{
	if (group == 1)
	{
		city[city_amount + 1][1] = p;
	}
	else if (group == 0)
	{
		city[0][0] = p;
	}
	else
	{
		cout << "ERROR! #444" << endl;
	}
}

wushi *city_ys[22][2];

// ��ʿǰ��
void wushi_forward()
{
	int i = 1;
	// ����һ����ʿ���ݹ����������
	for (int i = 0; i <= city_amount + 1; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			city_ys[i][j] = city[i][j];
		}
	}

	// ʵ�ʵ���ʿ�ƶ�
	for (i = city_amount + 1; i >= 1; i--)
	{
		if (city[i - 1][0] != nullptr)
		{
			city[i][0] = city[i - 1][0];
			city[i - 1][0] = nullptr;
			city[i][0]->after_forward();
		}
	}
	for (int i = 0; i <= city_amount; i++)
	{
		if (city[i + 1][1] != nullptr)
		{
			city[i][1] = city[i + 1][1];
			city[i + 1][1] = nullptr;
			city[i][1]->after_forward();
		}
	}

	// ����Ϊʵ�ʲ������֣������Ϊ��Ϣ���

	i = 1;

	if (city_ys[i][1] != nullptr)
	{

		cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
		cout << group_color[city_ys[i][1]->s_wushi_group()] << " " << wushi_mode[city_ys[i][1]->s_wushi_mode()] << " " << city_ys[i][1]->s_wushi_num() << " reached red headquarter";
		cout << " with " << city[i - 1][1]->s_wushi_HP() << " elements and force " << city[i - 1][1]->s_wushi_atk() << endl;

		silingbu_enemynum[0] += 1;
		if (silingbu_enemynum[0] >= 2)
		{
			cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
			cout << "red headquarter was taken" << endl;
			win_or_lose = true;
		}
	}

	for (i = 1; i <= city_amount; i++)
	{
		if (city_ys[i - 1][0] != nullptr)
		{

			cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
			cout << group_color[city_ys[i - 1][0]->s_wushi_group()] << " " << wushi_mode[city_ys[i - 1][0]->s_wushi_mode()] << " " << city_ys[i - 1][0]->s_wushi_num() << " marched to city ";
			cout << i << " with " << city[i][0]->s_wushi_HP() << " elements and force " << city[i][0]->s_wushi_atk() << endl;
		}
		if (city_ys[i + 1][1] != nullptr)
		{
			cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
			cout << group_color[city_ys[i + 1][1]->s_wushi_group()] << " " << wushi_mode[city_ys[i + 1][1]->s_wushi_mode()] << " " << city_ys[i + 1][1]->s_wushi_num() << " marched to city ";
			cout << i << " with " << city[i][1]->s_wushi_HP() << " elements and force " << city[i][1]->s_wushi_atk() << endl;
		}
	}
	i = city_amount + 1;

	if (city_ys[i - 1][0] != nullptr)
	{

		cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
		cout << group_color[city_ys[i - 1][0]->s_wushi_group()] << " " << wushi_mode[city_ys[i - 1][0]->s_wushi_mode()] << " " << city_ys[i - 1][0]->s_wushi_num() << " reached blue headquarter";
		cout << " with " << city[i][0]->s_wushi_HP() << " elements and force " << city[i][0]->s_wushi_atk() << endl;

		silingbu_enemynum[1] += 1;
		if (silingbu_enemynum[1] >= 2)
		{
			cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
			cout << "blue headquarter was taken" << endl;
			win_or_lose = true;
		}
	}
}

// ÿ����ʿ�㱨����������£�
void warrior_check()
{
	for (int i = 0; i <= city_amount + 1; i++)
	{
		if (city[i][0] != nullptr)
		{
			cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
			cout << group_color[city[i][0]->s_wushi_group()] << " " << wushi_mode[city[i][0]->s_wushi_mode()] << " " << city[i][0]->s_wushi_num() << " has ";
			bool flag_114514 = false;
			for (int k = 2; k >= 0; k--)
			{
				if (city[i][0]->get_weapon(k) != nullptr)
				{
					if (flag_114514)
					{
						cout << ",";
					}
					flag_114514 = true;
					cout << weapon_mode[k];
					if (city[i][0]->get_weapon(k)->get_info() != -1)
					{
						cout << "(" << city[i][0]->get_weapon(k)->get_info() << ")";
					}
				}
			}
			if (!flag_114514)
			{
				cout << "no weapon";
			}
			cout << endl;
		}
	}
	for (int i = 0; i <= city_amount + 1; i++)
	{
		if (city[i][1] != nullptr)
		{
			cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
			cout << group_color[city[i][1]->s_wushi_group()] << " " << wushi_mode[city[i][1]->s_wushi_mode()] << " " << city[i][1]->s_wushi_num() << " has ";
			bool flag_114514 = false;
			for (int k = 2; k >= 0; k--)
			{
				if (city[i][1]->get_weapon(k) != nullptr)
				{
					if (flag_114514)
					{
						cout << ",";
					}
					flag_114514 = true;
					cout << weapon_mode[k];
					if (city[i][1]->get_weapon(k)->get_info() != -1)
					{
						cout << "(" << city[i][1]->get_weapon(k)->get_info() << ")";
					}
				}
			}
			if (!flag_114514)
			{
				cout << "no weapon";
			}
			cout << endl;
		}
	}
}

wushi *city_lion_HP[30][2];

// wolf�ɻ���
void wolf_win(wushi *wolf, wushi *loser)
{
	for (int j = 0; j < 3; j++)
	{
		if (wolf->get_weapon(j) == nullptr && loser->get_weapon(j) != nullptr)
		{
			// cout << wolf->get_weapon(j) << "wolf��ȡ����" << endl;
			wolf->have_weapon(j, loser->get_weapon(j));
		}
	}
}

// ʤ����������
void after_battle_win(int i, int winner)
{
	if (winner == 0)
	{
		city[i][0]->Iwin(true);
		if (city[i][1] != nullptr)
		{
			// ��ʨ��ս��Ѫ���Է�
			if (city[i][1]->s_wushi_mode() == 3)
			{
				city[i][0]->earnHP(city_lion_HP[i][1]->s_wushi_HP());
			}
			city[i][1]->Iwin(false);
		}
	}
	else if (winner == 1)
	{
		if (city[i][0] != nullptr)
		{
			// ��ʨ��ս��Ѫ���Է�
			if (city[i][0]->s_wushi_mode() == 3)
			{
				city[i][1]->earnHP(city_lion_HP[i][0]->s_wushi_HP());
			}
			city[i][0]->Iwin(false);
		}
		city[i][1]->Iwin(true);
	}
	else
	{
		if (city[i][0] != nullptr)
			city[i][0]->Iwin(false);
		if (city[i][1] != nullptr)
			city[i][1]->Iwin(false);
	}
	// dragon����
	if (winner != 1 && city[i][0] != nullptr && city[i][0]->s_wushi_mode() == 0 && ((i % 2 == 1 && city_flag_color[i][1] == -1) || (city_flag_color[i][1] == 0)))
	{
		if (city[i][0]->s_dragon_shiqi() > 0.8)
		{
			cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
			cout << group_color[city[i][0]->s_wushi_group()] << " " << wushi_mode[city[i][0]->s_wushi_mode()] << " " << city[i][0]->s_wushi_num();
			cout << " yelled in city " << i << endl;
		}
	}
	if (winner != 0 && city[i][1] != nullptr && city[i][1]->s_wushi_mode() == 0 && ((i % 2 == 0 && city_flag_color[i][1] == -1) || (city_flag_color[i][1] == 1)))
	{
		if (city[i][1]->s_dragon_shiqi() > 0.8)
		{
			cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
			cout << group_color[city[i][1]->s_wushi_group()] << " " << wushi_mode[city[i][1]->s_wushi_mode()] << " " << city[i][1]->s_wushi_num();
			cout << " yelled in city " << i << endl;
		}
	}

	// ����ֵ��ȡ
	if (winner == 0)
	{
		// cout << "����" << i << "���ʤ" << endl;
		if (red.HP_f() >= 8)
		{
			red.useHP(8);
			city[i][0]->earnHP(8);
		}
		red.earnHP(HP_city[i]);
		cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
		cout << group_color[city[i][0]->s_wushi_group()] << " " << wushi_mode[city[i][0]->s_wushi_mode()] << " " << city[i][0]->s_wushi_num();
		cout << " earned " << HP_city[i] << " elements for his headquarter" << endl;
		HP_city[i] = 0;
	}
	else if (winner == 1)
	{
		// cout << "����" << i << "b��ʤ" << endl;
		if (blue.HP_f() >= 8)
		{
			blue.useHP(8);
			city[i][1]->earnHP(8);
		}
		blue.earnHP(HP_city[i]);
		cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
		cout << group_color[city[i][1]->s_wushi_group()] << " " << wushi_mode[city[i][1]->s_wushi_mode()] << " " << city[i][1]->s_wushi_num();
		cout << " earned " << HP_city[i] << " elements for his headquarter" << endl;
		HP_city[i] = 0;
	}
	// else cout << "����" << i << "���˻�ʤ" << endl;

	// ��������
	if (winner == 0)
	{
		// cout << "winner0" << i << city_flag_color[i][0] << endl;

		if (city_flag_color[i][1] != 0)
		{
			if (city_flag_color[i][0] != 0)
			{
				city_flag_color[i][0] = 0;
			}
			else
			{
				city_flag_color[i][0] = -1;
				city_flag_color[i][1] = 0;
				cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
				cout << "red flag raised in city " << i << endl;
			}
		}
		else
		{
			city_flag_color[i][0] = -1;
		}
	}
	else if (winner == 1)
	{

		// cout << "winner1" << i <<city_flag_color[i][0]<< endl;
		if (city_flag_color[i][1] != 1)
		{
			if (city_flag_color[i][0] != 1)
			{
				city_flag_color[i][0] = 1;
			}
			else
			{
				city_flag_color[i][0] = -1;
				city_flag_color[i][1] = 1;
				cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
				cout << "blue flag raised in city " << i << endl;
			}
		}
		else
		{
			city_flag_color[i][0] = -1;
		}
	}
	else
	{
		city_flag_color[i][0] = -1;
	}

	if (winner == 0)
	{
		// wolf
		if (city[i][0]->s_wushi_mode() == 4)
		{
			wolf_win(city_wolfsearch[i][0], city_wolfsearch[i][1]);
		}
		city[i][1] = nullptr;
	}
	else if (winner == 1)
	{
		// wolf
		if (city[i][1]->s_wushi_mode() == 4)
		{
			wolf_win(city_wolfsearch[i][1], city_wolfsearch[i][0]);
		}
		city[i][0] = nullptr;
	}
}

// ս����������
void city_weapon_fight()
{
	// ��ʨ�ӿ���һ������
	for (int i = 0; i < 30; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			if (city[i][j] == nullptr)
			{
				city_lion_HP[i][j] = nullptr;
			}
			else
			{
				city_lion_HP[i][j] = new wushi(*city[i][j]);
			}
		}
	}

	for (int i = 1; i <= city_amount; i++)
	{
		int who_win = -1;
		if (city[i][0] != nullptr && city[i][1] != nullptr)
		{
			if ((i % 2 == 1 && city_flag_color[i][1] == -1) || (city_flag_color[i][1] == 0))
			{
				cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
				cout << group_color[city[i][0]->s_wushi_group()] << " " << wushi_mode[city[i][0]->s_wushi_mode()] << " " << city[i][0]->s_wushi_num();
				cout << " attacked ";
				cout << group_color[city[i][1]->s_wushi_group()] << " " << wushi_mode[city[i][1]->s_wushi_mode()] << " " << city[i][1]->s_wushi_num();
				cout << " in city " << i << " with " << city[i][0]->s_wushi_HP() << " elements and force " << city[i][0]->get_atk() << endl;
				int ttt = 0;
				if (city[i][0]->get_weapon(0) != nullptr)
				{
					ttt = city[i][0]->get_weapon(0)->get_info();
					if (city[i][0]->get_weapon(0)->after_attack_thing())
					{
						city[i][0]->delete_weapon(0);
					}
				}
				city[i][1]->hurt(ttt + city[i][0]->s_wushi_atk());
				if (city[i][1]->s_wushi_HP() <= 0)
				{
					cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
					cout << group_color[city[i][1]->s_wushi_group()] << " " << wushi_mode[city[i][1]->s_wushi_mode()] << " " << city[i][1]->s_wushi_num();
					cout << " was killed in city " << i << endl;
					who_win = 0;
				}
				else if (city[i][1]->s_wushi_mode() != 1)
				{ // nijia������
					ttt = 0;
					if (city[i][1]->get_weapon(0) != nullptr)
					{
						ttt = city[i][1]->get_weapon(0)->get_info();
						if (city[i][1]->get_weapon(0)->after_attack_thing())
						{
							city[i][1]->delete_weapon(0);
						}
					}
					city[i][0]->hurt(int(city[i][1]->s_wushi_atk() / 2) + ttt);
					cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
					cout << group_color[city[i][1]->s_wushi_group()] << " " << wushi_mode[city[i][1]->s_wushi_mode()] << " " << city[i][1]->s_wushi_num();
					cout << " fought back against ";
					cout << group_color[city[i][0]->s_wushi_group()] << " " << wushi_mode[city[i][0]->s_wushi_mode()] << " " << city[i][0]->s_wushi_num();
					cout << " in city " << i << endl;
					if (city[i][0]->s_wushi_HP() <= 0)
					{
						cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
						cout << group_color[city[i][0]->s_wushi_group()] << " " << wushi_mode[city[i][0]->s_wushi_mode()] << " " << city[i][0]->s_wushi_num();
						cout << " was killed in city " << i << endl;
						who_win = 1;
					}
				}
			}
			else
			{
				cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
				cout << group_color[city[i][1]->s_wushi_group()] << " " << wushi_mode[city[i][1]->s_wushi_mode()] << " " << city[i][1]->s_wushi_num();
				cout << " attacked ";
				cout << group_color[city[i][0]->s_wushi_group()] << " " << wushi_mode[city[i][0]->s_wushi_mode()] << " " << city[i][0]->s_wushi_num();
				cout << " in city " << i << " with " << city[i][1]->s_wushi_HP() << " elements and force " << city[i][1]->get_atk() << endl;
				int ttt = 0;
				if (city[i][1]->get_weapon(0) != nullptr)
				{
					ttt = city[i][1]->get_weapon(0)->get_info();
					if (city[i][1]->get_weapon(0)->after_attack_thing())
					{
						city[i][1]->delete_weapon(0);
					}
				}
				city[i][0]->hurt(ttt + city[i][1]->s_wushi_atk());
				if (city[i][0]->s_wushi_HP() <= 0)
				{
					cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
					cout << group_color[city[i][0]->s_wushi_group()] << " " << wushi_mode[city[i][0]->s_wushi_mode()] << " " << city[i][0]->s_wushi_num();
					cout << " was killed in city " << i << endl;
					who_win = 1;
				}
				else if (city[i][0]->s_wushi_mode() != 1)
				{ // nijia������
					ttt = 0;
					if (city[i][0]->get_weapon(0) != nullptr)
					{
						ttt = city[i][0]->get_weapon(0)->get_info();
						if (city[i][0]->get_weapon(0)->after_attack_thing())
						{
							city[i][0]->delete_weapon(0);
						}
					}
					city[i][1]->hurt(int(city[i][0]->s_wushi_atk() / 2) + ttt);
					cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
					cout << group_color[city[i][0]->s_wushi_group()] << " " << wushi_mode[city[i][0]->s_wushi_mode()] << " " << city[i][0]->s_wushi_num();
					cout << " fought back against ";
					cout << group_color[city[i][1]->s_wushi_group()] << " " << wushi_mode[city[i][1]->s_wushi_mode()] << " " << city[i][1]->s_wushi_num();
					cout << " in city " << i << endl;
					if (city[i][1]->s_wushi_HP() <= 0)
					{
						cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
						cout << group_color[city[i][1]->s_wushi_group()] << " " << wushi_mode[city[i][1]->s_wushi_mode()] << " " << city[i][1]->s_wushi_num();
						cout << " was killed in city " << i << endl;
						who_win = 0;
					}
				}
			}
		}
		else if (is_arrow_battle[i])
		{
			if (city[i][0] != nullptr)
			{
				who_win = 0;
			}
			else if (city[i][1] != nullptr)
			{
				who_win = 1;
			}
			else
			{
				who_win = -1;
				is_arrow_battle[i] = false;
				continue;
			}
			is_arrow_battle[i] = false;
		}
		else
		{
			continue;
		}
		after_battle_win(i, who_win);
	}
}

// ���в�������Ԫ
void HP_generate()
{
	for (int i = 1; i <= city_amount; i++)
	{
		HP_city[i] += 10;
	}
	return;
}

// ��ȡ��������Ԫ
void get_city_HP()
{
	for (int i = 1; i <= city_amount; i++)
	{
		if (city[i][0] != nullptr && city[i][1] == nullptr)
		{
			red.earnHP(HP_city[i]);
			cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
			cout << group_color[city[i][0]->s_wushi_group()] << " " << wushi_mode[city[i][0]->s_wushi_mode()] << " " << city[i][0]->s_wushi_num();
			cout << " earned " << HP_city[i] << " elements for his headquarter" << endl;
			HP_city[i] = 0;
		}
		else if (city[i][0] == nullptr && city[i][1] != nullptr)
		{
			blue.earnHP(HP_city[i]);
			cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
			cout << group_color[city[i][1]->s_wushi_group()] << " " << wushi_mode[city[i][1]->s_wushi_mode()] << " " << city[i][1]->s_wushi_num();
			cout << " earned " << HP_city[i] << " elements for his headquarter" << endl;
			HP_city[i] = 0;
		}
	}
	return;
}

// �ż�
void arrow_attack()
{
	for (int i = 0; i < 30; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			city_wolfsearch[i][j] = city[i][j];
		}
	}
	for (int i = 1; i <= city_amount; i++)
	{
		is_arrow_battle[i] = false;
	}
	bool deadflag_1[30][2] = {false};
	for (int i = 1; i <= city_amount; i++)
	{
		if (city[i][0] != nullptr && city[i + 1][1] != nullptr)
		{
			if (city[i][0]->get_weapon(2) != nullptr)
			{
				city[i + 1][1]->hurt(arrow_R);
				if (city[i][0]->get_weapon(2)->after_attack_thing())
				{
					city[i][0]->delete_weapon(2);
				}
				cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
				cout << group_color[city[i][0]->s_wushi_group()] << " " << wushi_mode[city[i][0]->s_wushi_mode()] << " " << city[i][0]->s_wushi_num() << " shot";
				if (city[i + 1][1]->s_wushi_HP() <= 0)
				{
					is_arrow_battle[i + 1] = true;
					deadflag_1[i + 1][1] = true;
					cout << " and killed " << group_color[city[i + 1][1]->s_wushi_group()] << " " << wushi_mode[city[i + 1][1]->s_wushi_mode()] << " " << city[i + 1][1]->s_wushi_num();
				}
				cout << endl;
			}
		}
		if (city[i][1] != nullptr && city[i - 1][0] != nullptr)
		{
			if (city[i][1]->get_weapon(2) != nullptr)
			{
				city[i - 1][0]->hurt(arrow_R);
				if (city[i][1]->get_weapon(2)->after_attack_thing())
				{
					city[i][1]->delete_weapon(2);
				}
				cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
				cout << group_color[city[i][1]->s_wushi_group()] << " " << wushi_mode[city[i][1]->s_wushi_mode()] << " " << city[i][1]->s_wushi_num() << " shot";
				if (city[i - 1][0]->s_wushi_HP() <= 0)
				{
					is_arrow_battle[i - 1] = true;
					deadflag_1[i - 1][0] = true;
					cout << " and killed " << group_color[city[i - 1][0]->s_wushi_group()] << " " << wushi_mode[city[i - 1][0]->s_wushi_mode()] << " " << city[i - 1][0]->s_wushi_num();
				}
				cout << endl;
			}
		}
	}
	for (int i = 0; i <= city_amount + 1; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			if (deadflag_1[i][j])
			{
				city[i][j] = nullptr;
			}
		}
	}
	return;
}

// bomb��������
void bomb_attack()
{
	for (int i = 1; i <= city_amount; i++)
	{
		if (city[i][0] != nullptr && city[i][1] != nullptr)
		{
			// �칥
			if ((i % 2 == 1 && city_flag_color[i][1] == -1) || (city_flag_color[i][1] == 0))
			{
				int ttt = 0;
				if (city[i][0]->get_weapon(0) != nullptr)
				{
					ttt = city[i][0]->get_weapon(0)->get_info();
				}
				if (ttt + city[i][0]->s_wushi_atk() >= city[i][1]->s_wushi_HP())
				{
					if (city[i][1]->get_weapon(1) != nullptr)
					{
						cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
						cout << group_color[city[i][1]->s_wushi_group()] << " " << wushi_mode[city[i][1]->s_wushi_mode()] << " " << city[i][1]->s_wushi_num();
						cout << " used a bomb and killed ";
						cout << group_color[city[i][0]->s_wushi_group()] << " " << wushi_mode[city[i][0]->s_wushi_mode()] << " " << city[i][0]->s_wushi_num();
						cout << endl;
						city[i][0] = nullptr;
						city[i][1] = nullptr;
					}
				}
				else if (city[i][1]->s_wushi_mode() != 1)
				{ // nijia������
					ttt = 0;
					if (city[i][1]->get_weapon(0) != nullptr)
					{
						ttt = city[i][1]->get_weapon(0)->get_info();
					}
					if (ttt + int(city[i][1]->s_wushi_atk() / 2) >= city[i][0]->s_wushi_HP())
					{
						if (city[i][0]->get_weapon(1) != nullptr)
						{
							cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
							cout << group_color[city[i][0]->s_wushi_group()] << " " << wushi_mode[city[i][0]->s_wushi_mode()] << " " << city[i][0]->s_wushi_num();
							cout << " used a bomb and killed ";
							cout << group_color[city[i][1]->s_wushi_group()] << " " << wushi_mode[city[i][1]->s_wushi_mode()] << " " << city[i][1]->s_wushi_num();
							cout << endl;
							city[i][0] = nullptr;
							city[i][1] = nullptr;
						}
					}
				}
			}
			else
			{
				int ttt = 0;
				if (city[i][1]->get_weapon(0) != nullptr)
				{
					ttt = city[i][1]->get_weapon(0)->get_info();
				}
				if (ttt + city[i][1]->s_wushi_atk() >= city[i][0]->s_wushi_HP())
				{
					if (city[i][0]->get_weapon(1) != nullptr)
					{
						cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
						cout << group_color[city[i][0]->s_wushi_group()] << " " << wushi_mode[city[i][0]->s_wushi_mode()] << " " << city[i][0]->s_wushi_num();
						cout << " used a bomb and killed ";
						cout << group_color[city[i][1]->s_wushi_group()] << " " << wushi_mode[city[i][1]->s_wushi_mode()] << " " << city[i][1]->s_wushi_num();
						cout << endl;
						city[i][0] = nullptr;
						city[i][1] = nullptr;
					}
				}
				else if (city[i][0]->s_wushi_mode() != 1)
				{ // nijia������
					ttt = 0;
					if (city[i][0]->get_weapon(0) != nullptr)
					{
						ttt = int(city[i][0]->get_weapon(0)->get_info() / 2);
					}
					if (ttt + int(city[i][0]->s_wushi_atk() / 2) >= city[i][1]->s_wushi_HP())
					{
						if (city[i][1]->get_weapon(1) != nullptr)
						{
							cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
							cout << group_color[city[i][1]->s_wushi_group()] << " " << wushi_mode[city[i][1]->s_wushi_mode()] << " " << city[i][1]->s_wushi_num();
							cout << " used a bomb and killed ";
							cout << group_color[city[i][0]->s_wushi_group()] << " " << wushi_mode[city[i][0]->s_wushi_mode()] << " " << city[i][0]->s_wushi_num();
							cout << endl;
							city[i][0] = nullptr;
							city[i][1] = nullptr;
						}
					}
				}
			}
		}
	}
}

// ��ʱ����
void game_timeline()
{
	time_total = 0;
	while (time_total <= time_goal && !win_or_lose)
	{

		// ��ʿ�������£�
		if (flag_create_wushi[0] == 0)
		{
			red.silingbu_wushi_create();
		}
		if (flag_create_wushi[1] == 0)
		{
			blue.silingbu_wushi_create();
		}

		time_total += 5;
		if (time_total > time_goal || win_or_lose)
			break;
		// lion���ܣ��£�
		timeline_lion_runaway();

		time_total += 5;
		if (time_total > time_goal || win_or_lose)
			break;
		// ��ʿǰ�����£�
		wushi_forward();

		time_total += 10;
		if (time_total > time_goal || win_or_lose)
			break;
		// ��������Ԫ���£�
		HP_generate();

		time_total += 10;
		if (time_total > time_goal || win_or_lose)
			break;
		// ��ȡ��������Ԫ���£�
		get_city_HP();

		time_total += 5;
		if (time_total > time_goal || win_or_lose)
			break;
		// ��ʿ�ż����£�
		arrow_attack();

		time_total += 3;
		if (time_total > time_goal || win_or_lose)
			break;
		// bomb����+����
		bomb_attack();

		time_total += 2;
		if (time_total > time_goal || win_or_lose)
			break;
		// cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
		// ս�����£�
		city_weapon_fight();

		time_total += 10;
		if (time_total > time_goal || win_or_lose)
			break;
		// ˾���������Ԫ���£�
		cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
		cout << red.HP_f() << " elements in red headquarter" << endl;
		cout << setw(3) << setfill('0') << time_total / 60 << ":" << setw(2) << setfill('0') << time_total % 60 << " ";
		cout << blue.HP_f() << " elements in blue headquarter" << endl;

		time_total += 5;
		if (time_total > time_goal || win_or_lose)
			break;
		// ÿ����ʿ��������������£�
		warrior_check();

		time_total += 5;
	}
}

int main()
{
	// ����ԭ�л�����
	//streambuf *orig_buf = std::cout.rdbuf();

	// ���ļ����ض������
	/*
	ofstream out("output.txt");
	if (out)
	{
		std::cout.rdbuf(out.rdbuf()); // �ؼ��ض������
	}
	*/
	int n;
	cin >> n;
	for (int mhx_tql = 0; mhx_tql < n; mhx_tql++)
	{
		cout << "Case " << mhx_tql + 1 << ":" << endl;
		game_init();
		int m;
		cin >> m;
		cin >> city_amount >> arrow_R >> lion_k >> time_goal;
		cin >> wushi_HP_init[0];
		wushi_HP_min = wushi_HP_init[0];
		for (int i = 1; i < 5; i++)
		{
			cin >> wushi_HP_init[i];
			wushi_HP_min = min(wushi_HP_init[i], wushi_HP_min);
		}
		for (int i = 0; i < 5; i++)
		{
			cin >> wushi_ATK_init[i];
		}
		red.silingbu_init(m, 0);
		blue.silingbu_init(m, 1);

		game_timeline();
	}

	return 0;
}
plaintext
2025春程序设计实习魔兽世界oj
https://www.cxxdgc.cn/blog/courseblog/2025spring/chengshe/moshoushijie
Author Cxxdgc
Published at 2025年3月22日
Comment seems to stuck. Try to refresh?✨