CCF 201609-3
#include <cmath>
#include <iostream>
#include <queue>
using namespace std;
int n;
struct Fellow{
int health,posi,attack;
};
struct Leader{
int health,attack;
}L[2];
vector< vector<Fellow> > f;
inline void putFellow(int term,int posi,int attack,int health){
f[term].insert(f[term].begin()+posi-1,Fellow{health,posi,attack});
}
inline void freeFellow(int term,int posi){
f[term].erase(f[term].begin()+posi-1);
}
void Attack(int term,int att,int def){
if(def==0){
L[term^1].health-=f[term][att-1].attack;
return;
}
f[term][att-1].health-=f[term^1][def-1].attack;
f[term^1][def-1].health-=f[term][att-1].attack;
if(f[term][att-1].health<=0)
freeFellow(term,att);
if(f[term^1][def-1].health<=0)
freeFellow(term^1,def);
}
int main(){
cin >> n;
int flag=0;
vector<Fellow> a,b;
f.push_back(a);
f.push_back(b);
L[0].health=L[1].health=30;
L[0].attack=L[1].attack=0;
for(int i=0;i<n;i++){
string op;
cin >> op;
if(op=="summon"){
int posi,attack,health;
cin >> posi >> attack >> health;
putFellow(flag,posi,attack,health);
}else if(op=="attack"){
int att,def;
cin >> att >> def;
Attack(flag,att,def);
}else{
flag^=1;
}
}
if(L[0].health>0 && L[1].health>0) cout << 0;
else if(L[0].health<=0 && L[1].health>0) cout << -1;
else cout << 1;
cout << endl;
for(int j=0;j<2;j++){
cout << L[j].health << endl;
cout << f[j].size();
for(int i=0;i<f[j].size();i++){
cout << ' ' << f[j][i].health;
}
cout << endl;
}
}