前言

C++程设实习中魔兽世界分为了四个小任务实现, 博主今天终于码完了魔兽四, 从魔兽一开始增补代码, 最终的代码量竟然有1600行, 也懒得优化了, 这里记录一下各个版本.

魔兽世界之一:备战

总时间限制: 1000ms 内存限制: 65536kB
描述
魔兽世界的西面是红魔军的司令部,东面是蓝魔军的司令部。两个司令部之间是依次排列的若干城市。 
红司令部,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武士。(为简单起见,不考虑单词的复数形式)注意,每制造出一个新的武士,都要输出此时司令部里共有多少个该种武士。

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
样例输出
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

AC代码为

#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <functional>

using namespace std;

int mytime, maxtime;
unsigned int healthPointList[5];
char* soliderTypeName[5]={"dragon","ninja","iceman","lion","wolf"};

class Solider {
private:
    unsigned int healthPoint;
    unsigned int No;
public:
    explicit Solider(unsigned int HP, unsigned int No):healthPoint(HP), No(No) {
    //    cout << "A Solider with " << HP << "HP was built!\n";
    };

    virtual ~Solider() = default;;

    //virtual Solider *create(unsigned int No);
};

class Dragon : public Solider {
private:
    //int healthPoint;
public:
    Dragon(unsigned int No) : Solider(healthPointList[0], No) {
    //    cout << "A Dragon was built!\n";
    }

    static Dragon *create(unsigned int No){
        return new Dragon(No);
    }
};

class Ninja : public Solider {
private:
    //int healthPoint;
public:
    Ninja(unsigned int No) : Solider(healthPointList[1], No) {
    //    cout << "A Ninja was built!\n";
    }

    static Ninja *create(unsigned int No){
        return new Ninja(No);
    }
};

class Iceman : public Solider {
private:
    //int healthPoint;
public:
    Iceman(unsigned int No) : Solider(healthPointList[2], No) {
    //    cout << "A Iceman was built!\n";
    }

    static Iceman *create(unsigned int No){
        return new Iceman(No);
    }
};

class Lion : public Solider {
private:
    //int healthPoint;
public:
    Lion(unsigned int No) : Solider(healthPointList[3], No) {
    //    cout << "A Lion was built!\n";
    }

    static Lion *create(unsigned int No){
        return new Lion(No);
    }
};

class Wolf : public Solider {
private:
    //int healthPoint;
public:
    Wolf(unsigned int No) : Solider(healthPointList[4], No) {
    //    cout << "A Wolf was built!\n";
    }

    static Wolf *create(unsigned int No){
        return new Wolf(No);
    }
};

typedef function<Solider*(unsigned int)> SoliderCreateType;

map<unsigned int,SoliderCreateType> _SoliderCreate;



void myprint(int tim, char* str, int soliderType, int soliderIndex,int soliderNum){
    printf("%03d ",tim);
    printf("%s %s %d born with strength %d,%d %s in %s headquarter\n", str, soliderTypeName[soliderType], soliderIndex, healthPointList[soliderType], soliderNum, soliderTypeName[soliderType], str);
    return;
}

class Headquarter {
private:
    vector<Solider*> soliderList;
    unsigned int soliderNumber[5];
    unsigned int healthPoint;
    unsigned int soliderTotalNumber;
    unsigned int soliderIndex, createIndex;
public:

    Headquarter(unsigned int HP) : healthPoint(HP) {
        soliderList.clear();
        memset(soliderNumber, 0, sizeof(soliderNumber));
        soliderTotalNumber = soliderIndex = createIndex = 0;
    }

    int makeSolider(int time, const int *order, char* str, int count) {
        if(count==5) {
            printf("%03d %s headquarter stops making warriors\n", time, str);
            return 0;
        }
        if (healthPoint >= healthPointList[order[createIndex % 5]]) {
            Solider *solider = _SoliderCreate[order[createIndex % 5]](++soliderIndex);
            soliderList.push_back(solider);

            soliderNumber[order[createIndex % 5]]++;
            soliderTotalNumber++;
            healthPoint -= healthPointList[order[createIndex % 5]];

            myprint(time, str, order[createIndex % 5], soliderIndex, soliderNumber[order[createIndex % 5]]);
            createIndex++;
            createIndex%=5;
            return 1;
        }
        else {
            createIndex++;
            createIndex%=5;
            return makeSolider(time, order, str, count+1);
        }
    }

};

int makeOrderA[5] = {2, 3, 4, 1, 0}, makeOrderB[5] = {3, 0, 1, 2, 4};

int init(){
    mytime=0;
    //scanf("%d", &maxtime);
    scanf("%d%d%d%d%d", &healthPointList[0], &healthPointList[1], &healthPointList[2], &healthPointList[3],
          &healthPointList[4]);
}


int deal() {
    int cycle;
    scanf("%d", &cycle);
    _SoliderCreate[0]=Dragon::create;
    _SoliderCreate[1]=Ninja::create;
    _SoliderCreate[2]=Iceman::create;
    _SoliderCreate[3]=Lion::create;
    _SoliderCreate[4]=Wolf::create;
    int count=0;
    while (count<cycle) {
        count++;
        cout<<"Case:"<<count<<endl;
        unsigned int HP;
        scanf("%d", &HP);
        init();
        Headquarter A(HP), B(HP);
        bool a=true, b=true;
        while (a||b){
            //printf("%d\n", mytime);
            if(a){
                if(!A.makeSolider(mytime, makeOrderA, "red", 0)){
                    a=false;
                }
            }
            if(b){
                if(!B.makeSolider(mytime, makeOrderB, "blue", 0)){
                    b=false;
                }
            }
            mytime++;
        }
    }
}

int main() {
    deal();

    return 0;
}

魔兽世界之二:装备

总时间限制: 1000ms 内存限制: 65536kB
描述
魔兽世界的西面是红魔军的司令部,东面是蓝魔军的司令部。两个司令部之间是依次排列的若干城市。 

红司令部,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
样例输出
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

AC代码:

#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <functional>


using namespace std;

unsigned int mytime;

unsigned int healthPointList[5];
char *soliderTypeName[5] = {"dragon", "ninja", "iceman", "lion", "wolf"};

unsigned int weapon[3];
char *weaponTypeName[3] = {"sword", "bomb", "arrow"};

int makeOrderA[5] = {2, 3, 4, 1, 0}, makeOrderB[5] = {3, 0, 1, 2, 4};


class Solider {
private:
    unsigned int healthPoint;
    unsigned int No;
public:
    explicit Solider(unsigned int HP, unsigned int No) : healthPoint(HP), No(No) {};

    virtual ~Solider() = default;;

    virtual void makeWeapon(int No){};

    virtual double getMorale(){};

    virtual vector<int> getWeaponList(){};

    virtual int getLoyalty(){};
};

class Dragon : public Solider {
private:
    vector<int> weaponList;
    double morale;
public:
    explicit Dragon(unsigned int No, unsigned int headquarterLeftHP) : Solider(healthPointList[0], No) {
        makeWeapon(No);
        morale = (double) headquarterLeftHP / (double) healthPointList[0];
    }

    static Dragon *create(unsigned int No, unsigned int headquarterLeftHP) {
        return new Dragon(No, headquarterLeftHP);
    }

    void makeWeapon(int No) override {
        weaponList.push_back(No % 3);
    }

    double getMorale() override {
        return morale;
    }

    vector<int> getWeaponList() override {
        return weaponList;
    }

};

class Ninja : public Solider {
private:
    vector<int> weaponList;
public:
    explicit Ninja(unsigned int No) : Solider(healthPointList[1], No) {
        makeWeapon(No);
    }

    static Ninja *create(unsigned int No, unsigned int headquarterLeftHP) {
        return new Ninja(No);
    }

    void makeWeapon(int No) override {
        weaponList.push_back(No % 3);
        weaponList.push_back((No + 1) % 3);
    }

    vector<int> getWeaponList() override {
        return weaponList;
    }

};

class Iceman : public Solider {
private:
    vector<int> weaponList;
public:
    explicit Iceman(unsigned int No) : Solider(healthPointList[2], No) {
        makeWeapon(No);
    }

    static Iceman *create(unsigned int No, unsigned int headquarterLeftHP) {
        return new Iceman(No);
    }

    void makeWeapon(int No) override {
        weaponList.push_back(No % 3);
    }

    vector<int> getWeaponList() override {
        return weaponList;
    }

};

class Lion : public Solider {
private:
    int loyalty;
public:
    explicit Lion(unsigned int No, unsigned int headquarterLeftHP) : Solider(healthPointList[3], No) {
        loyalty = headquarterLeftHP;
    }

    static Lion *create(unsigned int No, unsigned int headquarterLeftHP) {
        return new Lion(No, headquarterLeftHP);
    }

    int getLoyalty() override {
        return loyalty;
    }
};

class Wolf : public Solider {
private:

public:
    explicit Wolf(unsigned int No) : Solider(healthPointList[4], No) {

    }

    static Wolf *create(unsigned int No, unsigned int headquarterLeftHP) {
        return new Wolf(No);
    }
};

typedef function<Solider *(unsigned int, unsigned int)> SoliderCreateType;

map<unsigned int, SoliderCreateType> _SoliderCreate;


void myprint(Solider* solider, int tim, char *str, int soliderType, int soliderIndex, int soliderNum) {
    printf("%03d ", tim);
    printf("%s %s %d born with strength %d,%d %s in %s headquarter\n", str, soliderTypeName[soliderType], soliderIndex,
           healthPointList[soliderType], soliderNum, soliderTypeName[soliderType], str);
    switch (soliderType){
        case 0:
            printf("It has a %s,and it's morale is %.2f\n", weaponTypeName[solider->getWeaponList()[0]],solider->getMorale());
            break;
        case 1:
            printf("It has a %s and a %s\n", weaponTypeName[solider->getWeaponList()[0]], weaponTypeName[solider->getWeaponList()[1]]);
            break;
        case 2:
            printf("It has a %s\n", weaponTypeName[solider->getWeaponList()[0]]);
            break;
        case 3:
            printf("It's loyalty is %d\n", solider->getLoyalty());
            break;
        default:
            break;
    }
    return;
}

class Headquarter {
private:
    vector<Solider *> soliderList;
    unsigned int soliderNumber[5];
    unsigned int healthPoint;
    unsigned int soliderTotalNumber;
    unsigned int soliderIndex, createIndex;
public:

    Headquarter(unsigned int HP) : healthPoint(HP) {
        soliderList.clear();
        memset(soliderNumber, 0, sizeof(soliderNumber));
        soliderTotalNumber = soliderIndex = createIndex = 0;
    }

    int makeSolider(int time, const int *order, char *str, int count) {
        if (count == 5) {
            printf("%03d %s headquarter stops making warriors\n", time, str);
            return 0;
        }
        if (healthPoint >= healthPointList[order[createIndex % 5]]) {
            int soliderTypeIndex=order[createIndex%5];
            healthPoint -= healthPointList[soliderTypeIndex];

            Solider *solider = _SoliderCreate[soliderTypeIndex](++soliderIndex, healthPoint);
            soliderList.push_back(solider);

            soliderNumber[soliderTypeIndex]++;
            soliderTotalNumber++;


            myprint( solider, time, str, soliderTypeIndex, soliderIndex, soliderNumber[soliderTypeIndex]);

            createIndex++;
            createIndex %= 5;
            return 1;
        } else {
            createIndex++;
            createIndex %= 5;
            return makeSolider(time, order, str, count + 1);
        }
    }

};



int init() {
    mytime = 0;

    scanf("%d%d%d%d%d", &healthPointList[0], &healthPointList[1], &healthPointList[2], &healthPointList[3],
          &healthPointList[4]);
}


int deal() {
    int cycle;
    scanf("%d", &cycle);
    _SoliderCreate[0] = Dragon::create;
    _SoliderCreate[1] = Ninja::create;
    _SoliderCreate[2] = Iceman::create;
    _SoliderCreate[3] = Lion::create;
    _SoliderCreate[4] = Wolf::create;
    int casecount=0;
    while (casecount<cycle) {
        cout<<"Case:"<<++casecount<<endl;
        unsigned int HP;
        scanf("%d", &HP);
        init();
        Headquarter A(HP), B(HP);
        bool a = true, b = true;
        while (a || b) {
            //printf("%d\n", mytime);
            if (a) {
                if (!A.makeSolider(mytime, makeOrderA, "red", 0)) {
                    a = false;
                }
            }
            if (b) {
                if (!B.makeSolider(mytime, makeOrderB, "blue", 0)) {
                    b = false;
                }
            }
            mytime++;
        }
    }
}

int main() {
    deal();

    return 0;
}

魔兽世界三(开战)

总时间限制: 2000ms 内存限制: 65536kB
描述
魔兽世界的西面是红魔军的司令部,东面是蓝魔军的司令部。两个司令部之间是依次排列的若干城市,城市从西向东依次编号为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

2) lion逃跑

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

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

3) 武士前进到某一城市

输出样例:



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

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

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

4) 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。为简单起见,武器不写复数形式

5) 报告战斗情况

战斗只有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

注意,把红武士写前面

6) 武士欢呼

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

7) 武士抵达敌军司令部

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

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

8) 司令部被占领

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

AC代码:

#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <functional>
#include <list>
#include <algorithm>
#include <cassert>

using namespace std;

int M, N, K, T;

int OriginHP[5];
int OriginSoliderATK[5];

char *soliderName[5] = {"dragon", "ninja", "iceman", "lion", "wolf"};
char *weaponName[3] = {"sword", "bomb", "arrow"};

int makeOrderRed[5] = {2, 3, 4, 1, 0}, makeOrderBlue[5] = {3, 0, 1, 2, 4};

class Weapon {
public:
    int ATK;
    int ATKself;
    bool useful = true;
    int time;
    int no;

    Weapon(int atk, int atkself = 0, int tim = 0) : ATK(atk), ATKself(atkself), time(tim) {
        //printf("Weapon with %d atk & %d atkself was built! Its usetime is %d\n", atk, atkself, tim);
    }

    virtual void updateATK(int soliderATK) {}

    virtual int use() {}

};

class Sword : public Weapon {
public:
    Sword(int SoliderATK) : Weapon(SoliderATK * 2 / 10) {
        //printf("Sword with %d atk was built!\n", SoliderATK * 2 / 10);
        no = 0;
    }

    int use() override {
        //printf("Use Sword with %d atk!\n", Weapon::ATK);
        return Weapon::ATK;
    }

    void updateATK(int soliderATK) {
        ATK = soliderATK * 2 / 10;
    }

    static Sword *create(int SoliderATK) {
        return new Sword(SoliderATK);
    }

};

class Bomb : public Weapon {
public:
    Bomb(int SoliderATK) : Weapon(SoliderATK * 4 / 10, SoliderATK * 4 / 10 / 2) {
        //printf("Bomb with %d atk & %d atkself was built!\n", SoliderATK * 4 / 10, SoliderATK * 4 / 10 / 2);
        no = 1;
    }

    int use() override {
        Weapon::useful = false;
        //printf("Use Bomb with %d atk & %d atkself!\n", Weapon::ATK, Weapon::ATKself);
        return Weapon::ATK;
    }

    void updateATK(int soliderATK) {
        ATK = soliderATK * 4 / 10;
        ATKself = ATK / 2;
    }

    static Bomb *create(int SoliderATK) {
        return new Bomb(SoliderATK);
    }
};

class Arrow : public Weapon {
public:
    Arrow(int SoliderATK) : Weapon(SoliderATK * 3 / 10) {
        //printf("Arrow with %d atk was built!\n", SoliderATK * 3 / 10);
        no = 2;
    }

    int use() override {
        Weapon::time++;
        //printf("Use Arrow with %d atk!\n", Weapon::ATK);
        if (Weapon::time == 2)
            Weapon::useful = false;
        return Weapon::ATK;
    }

    void updateATK(int soliderATK) {
        ATK = soliderATK * 3 / 10;
    }

    static Arrow *create(int SoliderATK) {
        return new Arrow(SoliderATK);
    }
};

typedef function<Weapon *(int)> CreateWeaponFunction;
map<int, CreateWeaponFunction> CreateWeapon;

bool lostWeaponCompare(Weapon *weapon1, Weapon *weapon2) {
    if (weapon1->no < weapon2->no)
        return true;
    else if (weapon1->no == weapon2->no) {
        return weapon1->time < weapon2->time;
    } else
        return false;
}

bool warWeaponCompare(Weapon *weapon1, Weapon *weapon2) {
    if (weapon1->no < weapon2->no)
        return true;
    else if (weapon1->no == weapon2->no) {
        return weapon1->time > weapon2->time;
    } else
        return false;
}

class Solider {
public:
    Weapon *weapon[10];
    int position;
    int HP;
    int No;
    int ATK;
    int team = 1;
    int loyalty;
    int weaponIndex = 0;
    int weaponNum[3] = {0, 0, 0};
    int weaponSum = 0;

    Solider(int no, int hp, int atk, int pos) : No(no), HP(hp), ATK(atk), position(pos) {
        //printf("Solider No.%d with %d HP was built at city %d! Its att is %d\n", no, hp, pos, atk);
        memset(weapon, 0, sizeof(weapon));
    }

    void setTeam() {
        team = -1;
    }

    virtual ~Solider() {
//        for (int i = 0; i < 10; i++) {
//            if (weapon[i]) {
//                printf("Solider No.%d 's weapon %d was delete!\n", Solider::No, i);
//                delete weapon[i];
//            }
//        }
//        printf("Solider No.%d with %d HP was delete!\n", No, HP);

    }

    virtual int setLoyalty(int headquarterLeftHP) {}

    virtual void goForward() {}

    virtual int escape() {
        return 0;
    }

    void lostSortWeapon() {
        int num = 0;
        while (weapon[num])
            num++;
        sort(weapon, weapon + num, lostWeaponCompare);
    }

    void sortWeapon() {
        int num = 0;
        while (weapon[num])
            num++;
        sort(weapon, weapon + num, warWeaponCompare);
        weaponIndex = 0;
        weaponSum = num;
    }

    void countWeapon() {
        memset(weaponNum, 0, sizeof(weaponNum));
        for (int i = 0; i < 10; i++) {
            if (weapon[i]) {
                weaponNum[weapon[i]->no]++;
            }
        }
    }

    bool isalive() {
        return HP > 0;
    }

    void delWeapon(int index) {
        delete weapon[index];
        weapon[index] = nullptr;

        for (; index < weaponSum - 1; index++) {
            weapon[index] = weapon[index + 1];
            weapon[index + 1] = nullptr;
        }

        weaponSum--;

    }

    virtual int useWeapon() {
        if (weapon[0] == nullptr) {
            return 0;
        }
        weaponIndex = weaponIndex % weaponSum;
        weapon[weaponIndex]->updateATK(ATK);
        int type = weapon[weaponIndex]->no;
        if (type == 1)
            HP -= weapon[weaponIndex]->ATKself;
        int atk = weapon[weaponIndex]->use();
        if (!weapon[weaponIndex]->useful) {
            delWeapon(weaponIndex);
            return atk;
        }
        weaponIndex++;
        return atk;
    }

    virtual void yep(int mytime) {}

};

class City {
public:
    Solider *cityredsolider;
    Solider *citybluesolider;

    City() {
        cityredsolider = citybluesolider = nullptr;
    }

    ~City() {
//        if (cityredsolider) {
//            delete cityredsolider;
//            cityredsolider = nullptr;
//        }
//        if (citybluesolider) {
//            delete citybluesolider;
//            citybluesolider = nullptr;
//        }
    }
};

City *city;

class Dragon : public Solider {
public:

    Dragon(int no, int pos) : Solider(no, OriginHP[0], OriginSoliderATK[0], pos) {
        //printf("Dragon No.%d with %d HP was built! Its att is %d\n", no, OriginHP[0], OriginSoliderATK[0]);
        weapon[0] = CreateWeapon[no % 3](OriginSoliderATK[0]);
    }

    ~Dragon() override {
        for (int i = 0; i < 10; i++) {
            if (weapon[i]) {
                //printf("Dragon No.%d 's weapon %d was delete!\n", Solider::No, i);
                delete weapon[i];
            }
        }
        //printf("Dragon No.%d with %d HP was delete at city %d!\n", Solider::No, Solider::HP, Solider::position);
    }

    static Dragon *create(int no, int pos) {
        return new Dragon(no, pos);
    }

    void goForward() override {
        Solider::position += Solider::team;
        //printf("Dragon No.%d with %d HP is in city %d now!\n", Solider::No, Solider::HP, Solider::position);
    }

    void yep(int mytime) {
        if (team == 1)
            printf("%03d:40 red dragon %d yelled in city %d\n", mytime, No, position);
        else
            printf("%03d:40 blue dragon %d yelled in city %d\n", mytime, No, position);
    }

};

class Ninja : public Solider {
public:

    Ninja(int no, int pos) : Solider(no, OriginHP[1], OriginSoliderATK[1], pos) {
        //printf("Ninga No.%d with %d HP was built at city %d! Its att is %d\n", no, OriginHP[1], pos, OriginSoliderATK[1]);
        weapon[0] = CreateWeapon[no % 3](OriginSoliderATK[1]);
        weapon[1] = CreateWeapon[(no + 1) % 3](OriginSoliderATK[1]);
    }

    ~Ninja() override {
        for (int i = 0; i < 10; i++) {
            if (weapon[i]) {
                //printf("Ninja No.%d 's weapon %d was delete!\n", Solider::No, i);
                delete weapon[i];
            }
        }
        //printf("Ninja No.%d with %d HP was delete at city %d!\n", Solider::No, Solider::HP, Solider::position);
    }

    static Ninja *create(int no, int pos) {
        return new Ninja(no, pos);
    }

    void goForward() override {
        Solider::position += Solider::team;
        //printf("Ninja No.%d with %d HP is in city %d now!\n", Solider::No, Solider::HP, Solider::position);
    }

    int useWeapon() {
        if (weapon[0] == nullptr) {
            return 0;
        }
        weaponIndex = weaponIndex % weaponSum;
        weapon[weaponIndex]->updateATK(ATK);
        int type = weapon[weaponIndex]->no;

        int atk = weapon[weaponIndex]->use();
        if (!weapon[weaponIndex]->useful) {
            Solider::delWeapon(weaponIndex);
            return atk;
        }
        weaponIndex++;
        return atk;
    }

};

class Iceman : public Solider {
public:

    Iceman(int no, int pos) : Solider(no, OriginHP[2], OriginSoliderATK[2], pos) {
        //printf("Iceman No.%d with %d HP was built at city %d! Its att is %d\n", no, OriginHP[2], pos, OriginSoliderATK[2]);
        weapon[0] = CreateWeapon[no % 3](OriginSoliderATK[2]);
    }

    ~Iceman() override {
        for (int i = 0; i < 10; i++) {
            if (weapon[i]) {
                //printf("Iceman No.%d 's weapon %d was delete!\n", Solider::No, i);
                delete weapon[i];
            }
        }
        //printf("Iceman No.%d with %d HP was delete at city %d!\n", Solider::No, Solider::HP, Solider::position);
    }

    static Iceman *create(int no, int pos) {
        return new Iceman(no, pos);
    }

    void goForward() override {
        Solider::position += Solider::team;
        Solider::HP -= Solider::HP / 10;
        //printf("Iceman No.%d with %d HP is in city %d now!\n", Solider::No, Solider::HP, Solider::position);
    }

};

class Lion : public Solider {
public:


    Lion(int no, int pos) : Solider(no, OriginHP[3], OriginSoliderATK[3], pos) {
        //printf("Lion No.%d with %d HP was built at city %d! Its att is %d\n", no, OriginHP[3], pos, OriginSoliderATK[3]);
        weapon[0] = CreateWeapon[no % 3](OriginSoliderATK[3]);
    }

    ~Lion() override {
        for (int i = 0; i < 10; i++) {
            if (weapon[i]) {
                //printf("Lion No.%d 's weapon %d was delete!\n", Solider::No, i);
                delete weapon[i];
            }
        }
        //printf("Lion No.%d with %d HP was delete at city %d!\n", Solider::No, Solider::HP, Solider::position);
    }

    int setLoyalty(int headquarterLeftHP) override {
        loyalty = headquarterLeftHP;
        return loyalty;
    }

    static Lion *create(int no, int pos) {
        return new Lion(no, pos);
    }

    void goForward() override {
        Solider::position += Solider::team;
        loyalty -= K;
        //printf("Lion No.%d with %d HP & %d loyalty is in city %d now!\n", Solider::No, Solider::HP, loyalty, Solider::position);
    }

    int escape() override {
        if (position == N + 1 || position == 0)
            return 0;
        if (loyalty <= 0)
            return 1;
        return 0;
    }

};

class Wolf : public Solider {
public:

    Wolf(int no, int pos) : Solider(no, OriginHP[4], OriginSoliderATK[4], pos) {
        //printf("Wolf No.%d with %d HP was built at city %d! Its att is %d\n", no, OriginHP[4], pos, OriginSoliderATK[4]);
    }

    ~Wolf() override {
        for (int i = 0; i < 10; i++) {
            if (weapon[i]) {
                //printf("Wolf No.%d 's weapon %d was delete!\n", Solider::No, i);
                delete weapon[i];
            }
        }
        //printf("Wolf No.%d with %d HP was delete at city!\n", Solider::No, Solider::HP);
    }

    static Wolf *create(int no, int pos) {
        return new Wolf(no, pos);
    }

    void goForward() override {
        Solider::position += Solider::team;
        //printf("Wolf No.%d with %d HP is in city %d now!\n", Solider::No, Solider::HP, Solider::position);
    }
};

typedef function<Solider *(int, int)> CreateSoliderFunction;
map<int, CreateSoliderFunction> CreateSolider;


class HeadQuarter {
public:
    list<Solider *> soliderList;
    int healthPoint;
    int position;
    int createIndex;
    int soliderIndex;


    HeadQuarter(int pos) : healthPoint(M), position(pos) {
        while (!soliderList.empty()) {
            delete soliderList.back();
            soliderList.pop_back();
        }
        createIndex = 0;
        soliderIndex = 0;
    }

    ~HeadQuarter() {

        list<Solider *>::iterator iter;
//        for(iter=soliderList.begin();iter!=soliderList.end();++iter){
//            cout<<(*iter)->No<<endl;
//        }

        while (!soliderList.empty()) {
            delete soliderList.back();
            soliderList.pop_back();
        }
    }

    int makeSolider(int time, const int *order, int flag = 0) {
        string str = position ? "blue" : "red";

        if (healthPoint >= OriginHP[order[createIndex % 5]]) {
            int soliderTypeIndex = order[createIndex % 5];
            healthPoint -= OriginHP[soliderTypeIndex];

            Solider *solider = CreateSolider[soliderTypeIndex](++soliderIndex, position);

            if (flag) {
                solider->setTeam();
                city[position].citybluesolider = solider;
            } else
                city[position].cityredsolider = solider;

            soliderList.push_back(solider);

            printf("%03d:00 %s %s %d born\n", time, str.c_str(), soliderName[soliderTypeIndex], soliderIndex);

            if (soliderTypeIndex == 3)
                printf("Its loyalty is %d\n", solider->setLoyalty(healthPoint));

            createIndex++;
            return 1;
        }
    }

};

HeadQuarter *RedTeam, *BlueTeam;

void make(int mytime) {
    //cout << mytime << "make\n";
    RedTeam->makeSolider(mytime, makeOrderRed);
    BlueTeam->makeSolider(mytime, makeOrderBlue, 1);
}

void escape(int mytime) {
    //cout << mytime << "escape\n";
    for (int i = 0; i <= N + 1; i++) {
        if (city[i].cityredsolider) {
            if (city[i].cityredsolider->escape()) {
                Solider *solider = city[i].cityredsolider;
                printf("%03d:05 red lion %d ran away\n", mytime, solider->No);

                city[i].cityredsolider = nullptr;
                RedTeam->soliderList.remove(solider);

                delete solider;
            }
        }
        if (city[i].citybluesolider) {
            if (city[i].citybluesolider->escape()) {
                Solider *solider = city[i].citybluesolider;
                printf("%03d:05 blue lion %d ran away\n", mytime, solider->No);

                city[i].citybluesolider = nullptr;
                BlueTeam->soliderList.remove(solider);

                delete solider;
            }
        }
    }
}

void reachEnemy(int mytime, int pos) {
    if (pos == N + 1) {
        Solider *solider = city[N + 1].cityredsolider;

        printf("%03d:10 red %s %d reached blue headquarter with %d elements and force %d\n",
               mytime, soliderName[makeOrderRed[(solider->No - 1) % 5]], solider->No, solider->HP, solider->ATK);


    } else if (pos == 0) {
        Solider *solider = city[0].citybluesolider;

        printf("%03d:10 blue %s %d reached red headquarter with %d elements and force %d\n",
               mytime, soliderName[makeOrderBlue[(solider->No - 1) % 5]], solider->No, solider->HP, solider->ATK);


    }
}

void victory(int mytime, int pos) {
    if (pos == N + 1)
        printf("%03d:10 blue headquarter was taken\n", mytime);
    else if (pos == 0)
        printf("%03d:10 red headquarter was taken\n", mytime);
}

bool goForward(int mytime) {
    //cout << mytime << "go forward\n";
    bool end = false;

    Solider *soliderredwest, *soliderredhere;

    if (city[1].citybluesolider) {
        if (city[0].citybluesolider) {}
        end = true;

        city[0].citybluesolider = city[1].citybluesolider;
        city[1].citybluesolider = nullptr;

        Solider *solider = city[0].citybluesolider;
        solider->goForward();
//        printf("%03d:10 blue %s %d marched to city %d with %d elements and force %d\n", mytime,
//               soliderName[makeOrderBlue[(solider->No - 1) % 5]], solider->No, solider->position, solider->HP,
//               solider->ATK);
        reachEnemy(mytime, 0);

        if (end)
            victory(mytime, 0);
    }

    soliderredwest = city[0].cityredsolider;
    city[0].cityredsolider = nullptr;

    for (int i = 1; i <= N; i++) {
        soliderredhere = city[i].cityredsolider;

        city[i].cityredsolider = soliderredwest;
        soliderredwest = soliderredhere;

        Solider *solider = city[i].cityredsolider;
        if (solider) {
            solider->goForward();
            printf("%03d:10 red %s %d marched to city %d with %d elements and force %d\n", mytime,
                   soliderName[makeOrderRed[(solider->No - 1) % 5]], solider->No, solider->position, solider->HP,
                   solider->ATK);
        }


        city[i].citybluesolider = city[i + 1].citybluesolider;
        city[i + 1].citybluesolider = nullptr;

        solider = city[i].citybluesolider;
        if (solider) {
            solider->goForward();
            printf("%03d:10 blue %s %d marched to city %d with %d elements and force %d\n", mytime,
                   soliderName[makeOrderBlue[(solider->No - 1) % 5]], solider->No, solider->position, solider->HP,
                   solider->ATK);
        }
    }

    if (soliderredwest) {
        if (city[N + 1].cityredsolider) {}
        end = true;

        city[N + 1].cityredsolider = soliderredwest;

        Solider *solider = city[N + 1].cityredsolider;
        solider->goForward();

        reachEnemy(mytime, N + 1);

//        printf("%03d:10 red %s %d marched to city %d with %d elements and force %d\n", mytime,
//               soliderName[makeOrderBlue[(solider->No - 1) % 5]], solider->No, solider->position, solider->HP,
//               solider->ATK);

        if (end)
            victory(mytime, N + 1);
    }

    if (end) {
        return true;
    }
    return false;
}

void wolfSteal(int mytime) {
    //cout << mytime << "wolfSteal\n";
    for (int i = 1; i <= N; i++) {
        if (city[i].cityredsolider && city[i].citybluesolider) {
            Solider *solider1, *solider2;
            solider1 = city[i].cityredsolider;
            solider2 = city[i].citybluesolider;

            if (makeOrderRed[(solider1->No - 1) % 5] == 4) {
                if (makeOrderBlue[(solider2->No - 1) % 5] == 4)
                    continue;

                int index = 0;
                while (solider1->weapon[index])
                    index++;
                solider2->lostSortWeapon();
                int count[3] = {0, 0, 0};

                //solider2->countWeapon();
                //printf("%d %d %d\n", solider2->weaponNum[0],solider2->weaponNum[1],solider2->weaponNum[2]);

                int no = (solider2->weapon[0]) ? solider2->weapon[0]->no : -1;

                while (index < 10 && solider2->weapon[0] && solider2->weapon[0]->no == no) {
                    solider1->weapon[index] = solider2->weapon[0];
                    count[solider1->weapon[index]->no]++;
                    int x;
                    for (x = 1; solider2->weapon[x]; x++)
                        solider2->weapon[x - 1] = solider2->weapon[x];
                    solider2->weapon[x - 1] = nullptr;
                    index++;
                }
                if (count[0] || count[1] || count[2]) {
                    printf("%03d:35 red wolf %d took ", mytime, solider1->No);
                    if (count[0]) {
                        printf("%d sword ", count[0]);
                    }
                    if (count[1]) {
                        printf("%d bomb ", count[1]);
                    }
                    if (count[2]) {
                        printf("%d arrow ", count[2]);
                    }
                    printf("from blue %s %d in city %d\n", soliderName[makeOrderBlue[(solider2->No - 1) % 5]],
                           solider2->No, solider1->position);
                }
            } else if (makeOrderBlue[(solider2->No - 1) % 5] == 4) {
                int index = 0;
                while (solider2->weapon[index])
                    index++;
                solider1->lostSortWeapon();
                int count[3] = {0, 0, 0};

                //solider1->countWeapon();
                //printf("%d %d %d\n", solider1->weaponNum[0],solider1->weaponNum[1],solider1->weaponNum[2]);

                int no = (solider1->weapon[0]) ? solider1->weapon[0]->no : -1;

                while (index < 10 && solider1->weapon[0] && solider1->weapon[0]->no == no) {
                    solider2->weapon[index] = solider1->weapon[0];
                    count[solider2->weapon[index]->no]++;
                    int x;
                    for (x = 1; solider1->weapon[x]; x++)
                        solider1->weapon[x - 1] = solider1->weapon[x];
                    solider1->weapon[x - 1] = nullptr;
                    index++;
                }
                if (count[0] || count[1] || count[2]) {
                    printf("%03d:35 blue wolf %d took ", mytime, solider2->No);
                    if (count[0]) {
                        printf("%d sword ", count[0]);
                    }
                    if (count[1]) {
                        printf("%d bomb ", count[1]);
                    }
                    if (count[2]) {
                        printf("%d arrow ", count[2]);
                    }
                    printf("from red %s %d in city %d\n", soliderName[makeOrderRed[(solider1->No - 1) % 5]],
                           solider1->No, solider1->position);
                }
            }
        }
    }
}


void warGetWeapon(Solider *solider1, Solider *solider2) {
    solider2->lostSortWeapon();

    int index = solider1->weaponSum;
    for (int i = 0; index < 10; index++) {
        solider1->weapon[index] = solider2->weapon[i];
        solider2->weapon[i] = nullptr;
        i++;
    }

}

void war(int mytime) {
    //cout << mytime << "war\n";
    for (int i = 1; i <= N; ++i) {
        if (city[i].citybluesolider && city[i].cityredsolider) {
//            if(city[i].cityredsolider==city[i].citybluesolider){
//                cout<<"Illegel!\n";
//            }
            //cout<<i%2<<endl;
            Solider *solider1 = ((i % 2) == 0) ? city[i].citybluesolider : city[i].cityredsolider;
            Solider *solider2 = ((i % 2) == 1) ? city[i].citybluesolider : city[i].cityredsolider;

            solider1->sortWeapon();
            solider2->sortWeapon();

            solider1->countWeapon();
            solider2->countWeapon();

            //printf("%d %d %d %d %d %d\n", solider1->team, solider1->No, solider1->HP, solider1->weaponNum[0], solider1->weaponNum[1], solider1->weaponNum[2]);
            //printf("%d %d %d %d %d %d\n", solider2->team, solider2->No, solider2->HP, solider2->weaponNum[0], solider2->weaponNum[1], solider2->weaponNum[2]);


            while (true) {
                solider1->countWeapon();
                int bomb1 = solider1->weaponNum[1], bomb2;
                int arrow1 = solider1->weaponNum[2], arrow2;

                int atkf1t2 = solider1->useWeapon();
                solider2->HP -= atkf1t2;
                //printf("solider1HP: %d, solider2HP: %d\n", solider1->HP, solider2->HP);
                int atkf2t1;
                if (solider1->isalive() && solider2->isalive()) {
                    solider2->countWeapon();
                    bomb2 = solider2->weaponNum[1];
                    arrow2 = solider2->weaponNum[2];

                    atkf2t1 = solider2->useWeapon();
                    solider1->HP -= atkf2t1;
                    //printf("solider1HP: %d, solider2HP: %d\n", solider1->HP, solider2->HP);
                }
                //cout<<bomb1<<" "<<arrow1<<" "<<bomb2<<" "<<arrow2<<" "<<atkf1t2<<" "<<atkf2t1<<endl;

                if (!solider1->isalive() && !solider2->isalive()) {

                    printf("%03d:40 both red %s %d and blue %s %d died in city %d\n", mytime,
                           soliderName[makeOrderRed[(city[i].cityredsolider->No - 1) % 5]],
                           city[i].cityredsolider->No,
                           soliderName[makeOrderBlue[(city[i].citybluesolider->No - 1) % 5]],
                           city[i].citybluesolider->No, solider1->position);

                    BlueTeam->soliderList.remove(city[i].citybluesolider);
                    RedTeam->soliderList.remove(city[i].cityredsolider);

                    city[i].cityredsolider = nullptr;
                    city[i].citybluesolider = nullptr;

                    delete solider1;
                    delete solider2;

                    solider1 = nullptr;
                    solider2 = nullptr;

                    break;

                } else if (!solider1->isalive()) {
                    //solider1挂了
                    warGetWeapon(solider2, solider1);

                    if (solider1 == city[i].citybluesolider) {
                        printf("%03d:40 red %s %d killed blue %s %d in city %d remaining %d elements\n", mytime,
                               soliderName[makeOrderRed[(city[i].cityredsolider->No - 1) % 5]],
                               city[i].cityredsolider->No,
                               soliderName[makeOrderBlue[(city[i].citybluesolider->No - 1) % 5]],
                               city[i].citybluesolider->No, solider1->position, solider2->HP);

                        city[i].citybluesolider = nullptr;
                        BlueTeam->soliderList.remove(solider1);
                    } else {
                        printf("%03d:40 blue %s %d killed red %s %d in city %d remaining %d elements\n", mytime,
                               soliderName[makeOrderBlue[(city[i].citybluesolider->No - 1) % 5]],
                               city[i].citybluesolider->No,
                               soliderName[makeOrderRed[(city[i].cityredsolider->No - 1) % 5]],
                               city[i].cityredsolider->No, solider1->position, solider2->HP);

                        city[i].cityredsolider = nullptr;
                        RedTeam->soliderList.remove(solider1);
                    }
                    delete solider1;
                    solider1 = nullptr;
                    break;
                } else if (!solider2->isalive()) {
                    //solider2挂了
                    warGetWeapon(solider1, solider2);

                    if (solider2 == city[i].citybluesolider) {
                        printf("%03d:40 red %s %d killed blue %s %d in city %d remaining %d elements\n", mytime,
                               soliderName[makeOrderRed[(city[i].cityredsolider->No - 1) % 5]],
                               city[i].cityredsolider->No,
                               soliderName[makeOrderBlue[(city[i].citybluesolider->No - 1) % 5]],
                               city[i].citybluesolider->No, solider1->position, solider1->HP);

                        city[i].citybluesolider = nullptr;
                        BlueTeam->soliderList.remove(solider2);

                    } else {
                        printf("%03d:40 blue %s %d killed red %s %d in city %d remaining %d elements\n", mytime,
                               soliderName[makeOrderBlue[(city[i].citybluesolider->No - 1) % 5]],
                               city[i].citybluesolider->No,
                               soliderName[makeOrderRed[(city[i].cityredsolider->No - 1) % 5]],
                               city[i].cityredsolider->No, solider1->position, solider1->HP);

                        city[i].cityredsolider = nullptr;
                        RedTeam->soliderList.remove(solider2);
                    }

                    delete solider2;
                    solider2 = nullptr;
                    break;

                } else {
                    if (atkf1t2 == 0 && atkf2t1 == 0 && arrow1 == 0 && arrow2 == 0 && bomb1 == 0 && bomb2 == 0) {
                        printf("%03d:40 both red %s %d and blue %s %d were alive in city %d\n", mytime,
                               soliderName[makeOrderRed[(city[i].cityredsolider->No - 1) % 5]],
                               city[i].cityredsolider->No,
                               soliderName[makeOrderBlue[(city[i].citybluesolider->No - 1) % 5]],
                               city[i].citybluesolider->No, solider1->position);
                        break;
                    }
                }
            }
            if (city[i].cityredsolider) {
                city[i].cityredsolider->yep(mytime);
            }
            if (city[i].citybluesolider) {
                city[i].citybluesolider->yep(mytime);
            }
        }
    }
}

void headQuarterReport(int mytime) {
    //cout << mytime << "headQuarterReport\n";
    printf("%03d:50 %d elements in red headquarter\n", mytime, RedTeam->healthPoint);
    printf("%03d:50 %d elements in blue headquarter\n", mytime, BlueTeam->healthPoint);
}

void soliderReport(int mytime) {
    //cout << mytime << "soliderReport\n";
    for (int i = 0; i <= N + 1; i++) {
        if (city[i].cityredsolider) {
            Solider *solider1 = city[i].cityredsolider;
            solider1->countWeapon();

            printf("%03d:55 red %s %d has %d sword %d bomb %d arrow and %d elements\n", mytime,
                   soliderName[makeOrderRed[(solider1->No - 1) % 5]], solider1->No, solider1->weaponNum[0],
                   solider1->weaponNum[1], solider1->weaponNum[2], solider1->HP);

        }
        if (city[i].citybluesolider) {
            Solider *solider1 = city[i].citybluesolider;
            solider1->countWeapon();

            printf("%03d:55 blue %s %d has %d sword %d bomb %d arrow and %d elements\n", mytime,
                   soliderName[makeOrderBlue[(solider1->No - 1) % 5]], solider1->No, solider1->weaponNum[0],
                   solider1->weaponNum[1], solider1->weaponNum[2], solider1->HP);
        }
    }
}


void init() {
    scanf("%d%d%d%d", &M, &N, &K, &T);
    scanf("%d%d%d%d%d", &OriginHP[0], &OriginHP[1], &OriginHP[2], &OriginHP[3], &OriginHP[4]);
    scanf("%d%d%d%d%d", &OriginSoliderATK[0], &OriginSoliderATK[1], &OriginSoliderATK[2], &OriginSoliderATK[3],
          &OriginSoliderATK[4]);

    RedTeam = new HeadQuarter(0);
    BlueTeam = new HeadQuarter(N + 1);
    city = new City[N + 2];
}

void deal() {
    int mytime = 0;
    while (60 * mytime <= T) {
        make(mytime);
        if (60 * mytime + 5 > T)
            break;
        escape(mytime);
        if (60 * mytime + 10 > T)
            break;
        if (goForward(mytime)) {
            break;
        }
        if (60 * mytime + 35 > T)
            break;
        wolfSteal(mytime);
        if (60 * mytime + 40 > T)
            break;
        war(mytime);
        if (60 * mytime + 50 > T)
            break;
        headQuarterReport(mytime);
        if (60 * mytime + 55 > T)
            break;
        soliderReport(mytime);
        mytime++;
    }
}

void release() {
    delete RedTeam;
    delete BlueTeam;
    delete[] city;
}

int main() {

    CreateWeapon[0] = Sword::create;
    CreateWeapon[1] = Bomb::create;
    CreateWeapon[2] = Arrow::create;

    CreateSolider[0] = Dragon::create;
    CreateSolider[1] = Ninja::create;
    CreateSolider[2] = Iceman::create;
    CreateSolider[3] = Lion::create;
    CreateSolider[4] = Wolf::create;

    int loop;
    scanf("%d", &loop);
    int caseout = 0;
    while (caseout < loop) {
        printf("Case %d:\n", ++caseout);
        init();
        deal();
        release();
    }
}

魔兽世界终极版

总时间限制: 6000ms 内存限制: 65536kB
描述
魔兽世界的西面是红魔军的司令部,东面是蓝魔军的司令部。两个司令部之间是依次排列的若干城市,城市从西向东依次编号为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

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

3) 武士前进到某一城市
输出样例: 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同归于尽。

6) 武士主动进攻
输出样例: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

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

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

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

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

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

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

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

13) 司令部被占领
输出样例: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
样例输出
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

AC代码:

此处内容需要评论回复后(审核通过)方可阅读。

最后修改:2020 年 10 月 24 日
如果觉得我的文章对你有用,请随意赞赏