思路:
首先考虑的是由n种操作,然后每种操作对应不同的代码,故写一个operation函数即可,然后对于summon操作,是增加一名守卫,利用per结构体以及vector构造的二维数组(第一维代表先手还是后手,第二维代表守卫的位置),可以方便的实现在指定位置增加或删除。
然后attack分类讨论,如果攻击对方英雄,则判断对面英雄血量是否阵亡,同理,若攻击对方守卫,判断是否阵亡以删去守卫,最后对于end操作,即更换先手,循环往复以上操作。最终将指定结果输出即可。
代码:
#include<bits/stdc++.h>
using namespace std;
int n,id,pos,at,he,p1,p2,h1=30,h2=30,win;
int size[2];
string s;
struct per{
int at,he;
per(int a,int b){
at=a;
he=b;
}
};
per init(0,0);
vector<vector<per>> followers(2,vector<per>(10,init));
void op(string s)
{
if(s&