大模拟
#include<iostream>
#include<sstream>
#include<vector>
using namespace std;
const int N = 5010;
string dt[N];
int n;
struct mos { int atk, hp; };
int hp[2] = { 30,30 };
vector<mos>m[2];
void start() {
stringstream ss;
int type = 0;//0先手英雄,1后手英雄
for (int i = 0; i < n; i++) {
ss.clear();
ss.str(dt[i]);
string action;
ss >> action;
if (action == "summon") {
int p, atk, hp;
ss >> p >> atk >> hp;
m[type].push_back({ atk,hp });
if (m[type].size() >= p) {
int t = m[type].size() - 1;
while (t != p - 1) {
swap(m[type][t], m[type][t - 1]);
t--;
}
}
}
else if (action == "attack") {
int p1, p2;
ss >> p1 >> p2;
if (p2 == 0) {
hp[type ^ 1] -= m[type][p1 - 1].atk;
if (hp[type ^ 1] <= 0)return;
}
else {
m[type][p1 - 1].hp -= m[type ^ 1][p2 - 1].atk;
m[type ^ 1][p2 - 1].hp -= m[type][p1 - 1].atk;
if (m[type][p1 - 1].hp <= 0)m[type].erase(m[type].begin() + p1 - 1);
if (m[type ^ 1][p2 - 1].hp <= 0)m[type ^ 1].erase(m[type ^ 1].begin() + p2 - 1);
}
}
else if (action == "end") {
type = type ^ 1;
}
}
}
int main() {
cin >> n;
getchar();
for (int i = 0; i < n; i++) {
string s;
getline(cin, s);
dt[i] = s;
}
start();
if (hp[0] <= 0)cout << -1 << endl;
else if (hp[1] <= 0)cout << 1 << endl;
else cout << 0 << endl;
for (int t = 0; t <= 1; t++) {
cout << hp[t] << endl;
cout<< m[t].size()<<' ';
for (int i = 0; i < m[t].size(); i++) {
cout << m[t][i].hp << ' ';
}
cout << endl;
}
}