金色传说!
#include<bits/stdc++.h>
using namespace std;
struct Node{
int health,attack;
};
struct node{
int health=30,num=0,att=0;
vector<Node> List;
}G[2];
int main(void)
{
int n,f=0,w=0;
cin>>n;
for(int i=0;i<n;i++){
string s;
int a=f%2,b=(f+1)%2;
cin>>s;
if(s[0]=='e')
f++;
else if(s[0]=='s'){
int p,he,ak;
cin>>p>>ak>>he;
G[a].num++;
G[a].List.insert(G[a].List.begin()+p-1,{he,ak});
}
else if(s[0]=='a'){
int ak,de;
cin>>ak>>de;
int g=G[a].List[ak-1].attack;
if(de==0){
G[b].health-=g;
if(G[b].health<=0){
if(b==1)
w=1;
if(b==0)
w=-1;
break;
}
}
else{
G[b].List[de-1].health-=g;
G[a].List[ak-1].health-=G[b].List[de-1].attack;
if(G[b].List[de-1].health<=0){
G[b].List.erase(G[b].List.begin()+de-1);
G[b].num--;
}
if(G[a].List[ak-1].health<=0){
G[a].List.erase(G[a].List.begin()+ak-1);
G[a].num--;
}
}
}
}
printf("%d\n",w);
printf("%d\n",G[0].health);
printf("%d",G[0].num);
for(int i=0;i<G[0].List.size();i++){
printf(" %d",G[0].List[i].health);
}
printf("\n");
printf("%d\n",G[1].health);
printf("%d",G[1].num);
for(int i=0;i<G[1].List.size();i++){
printf(" %d",G[1].List[i].health);
}
return 0;
}