CSP 炉石传说

在这里插入图片描述
作为一名年迈的炉石玩家,终于有机会参与到炉石的底层设计中了hhhhh

#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
int n;
int flag=0,player=0;

struct node{
    int ak,hp,v;
    node& operator=(const node&r)
        {ak=r.ak;hp=r.hp;v=r.v;}
    void insert(int _ak,int _hp,int _v)
        {ak=_ak;hp=_hp;v=_v;}
};
node A[10],B[10];

void summon(int p){
    int pos,ak,hp;
    scanf("%d%d%d",&pos,&ak,&hp);
    if(p==0){
        if(A[pos].v==0){A[pos].insert(ak,hp,1);}
        else for(int i=pos+1;i<=7;i++){
            if(A[i].v==0){
                for(int j=i;j>=pos+1;j--){
                    A[j]=A[j-1];
                }
                A[pos].insert(ak,hp,1);
                break;
            }
        }
    }
    else{
        if(B[pos].v==0){B[pos].insert(ak,hp,1);}
        else for(int i=pos+1;i<=7;i++){
            if(B[i].v==0){
                for(int j=i;j>=pos+1;j--){
                    B[j]=B[j-1];
                }
                B[pos].insert(ak,hp,1);
                break;
            }
        }
    }
    //printf("%d %d %d %d\n",A[1].ak,A[1].hp,A[2].ak,A[2].hp);
    //printf("%d %d %d %d\n",B[1].ak,B[1].hp,B[2].ak,B[2].hp);
}

void attack(int p){
    int p1,p2;
    scanf("%d%d",&p1,&p2);
    if(p==0){
        A[p1].hp-=B[p2].ak;
        B[p2].hp-=A[p1].ak;
        if(A[p1].hp<=0){
            if(p1==0){flag=-1;return;}
            for(int i=p1;i<=7;i++){
                A[i]=A[i+1];
            }
        }
        if(B[p2].hp<=0){
            if(p2==0){flag=1;return;}
            for(int i=p2;i<=7;i++){
                B[i]=B[i+1];
            }
        }
    }
    else{
        B[p1].hp-=A[p2].ak;
        A[p2].hp-=B[p1].ak;
        if(A[p2].hp<=0){
            if(p2==0){flag=-1;return;}
            for(int i=p2;i<=7;i++){
                A[i]=A[i+1];
            }
        }
        if(B[p1].hp<=0){
            if(p1==0){flag=1;return;}
            for(int i=p1;i<=7;i++){
                B[i]=B[i+1];
            }
        }
    }
}
int main(){
    //freopen("kk.txt","r",stdin);
    scanf("%d",&n);
    string s;
    A[0].ak=0;A[0].hp=30;
    B[0].ak=0;B[0].hp=30;
    while(n--){
        cin>>s;
        if(s[0]=='s'){summon(player);}
        else if(s[0]=='a'){attack(player);}
        else if(s[0]=='e'){player=1-player;}
        if(flag!=0)break;
    }

    queue<int>q1,q2;
    for(int i=1;i<=7;i++){
        if(A[i].v==1)q1.push(A[i].hp);
        if(B[i].v==1)q2.push(B[i].hp);
    }
    cout<<flag<<endl;
    cout<<A[0].hp<<endl;
    cout<<q1.size()<<" ";
    while(!q1.empty()){cout<<q1.front()<<" ";q1.pop();}
    cout<<endl;
    cout<<B[0].hp<<endl;
    cout<<q2.size()<<" ";
    while(!q2.empty()){cout<<q2.front()<<" ";q2.pop();}
    cout<<endl;
	return 0;
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值