CCF 201609-3

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;
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值