http://115.28.138.223/view.page?gpid=T45
模拟。
#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<vector> using namespace std; struct xx { int life,att; xx(int a,int b):life(a),att(b){}; }; vector<xx> v[2]; char op[10]; int main() { int n,flag = 0; v[0].push_back(xx(30,0)); v[1].push_back(xx(30,0)); scanf("%d",&n); while(n--) { scanf("%s",op); if(op[0] == 'e') flag ^= 1; else if(op[0] == 's') { int a,b,c; scanf("%d%d%d",&a,&b,&c); v[flag].insert(v[flag].begin()+a,xx(c,b)); } else { int a,b; scanf("%d%d",&a,&b); v[flag][a].life -= v[flag^1][b].att; v[flag^1][b].life -= v[flag][a].att; if(v[flag][a].life <= 0) v[flag].erase(v[flag].begin()+a); if(b != 0 && v[flag^1][b].life <= 0) v[flag^1].erase(v[flag^1].begin()+b); } //for(int i = 0;i < v[0].size();i++) printf("%d %d ",v[0][i].life,v[0][i].att); //for(int i = 0;i < v[1].size();i++) printf("%d %d ",v[1][i].life,v[1][i].att); } if(v[0][0].life <= 0) printf("-1 "); else if(v[1][0].life <= 0) printf("1 "); else printf("0 "); printf("%d %d ",v[0][0].life,v[0].size()-1); for(int i = 1;i < v[0].size();i++) printf("%d ",v[0][i].life); printf(" "); printf("%d %d ",v[1][0].life,v[1].size()-1); for(int i = 1;i < v[1].size();i++) printf("%d ",v[1][i].life); printf(" "); return 0; }