ccf 炉石传说

考试的时候写了现在两倍长的代码却只得了60分。〒▽〒〒▽〒〒▽〒。这题没有什么东西细心一点就行了。

#include<bits/stdc++.h>
using namespace std;
typedef struct
{
  int t,h;
}S;
S s[2][10];
int main()
{
	s[0][0].h=30;
	s[1][0].h=30;
	int n,a,b,d;
	int cnt;
	char c[20];
	scanf("%d",&n);
	S temp;
	int flag=0;
	while(n--)
	{
		scanf("%s",c);
		if(strcmp(c,"summon")==0)
		{
			scanf("%d %d %d",&a,&b,&d);
			temp.t=b,temp.h=d;
			for(int i=6;i>=a;i--)
			{
				s[flag%2][i+1]=s[flag%2][i];
			}
			s[flag%2][a]=temp;
		}
		if(strcmp(c,"attack")==0)
		{
			scanf("%d %d",&a,&b);
			S t1=s[flag%2][a];
			S t2=s[(flag+1)%2][b];
			s[flag%2][a].h-=t2.t;
			if(s[flag%2][a].h<=0)
			{
				for(int i=a;i<=6;i++)
				s[flag%2][i]=s[flag%2][i+1];
			}
			s[(flag+1)%2][b].h-=t1.t;
			if(s[(flag+1)%2][b].h<=0&&b!=0)
			{
				for(int i=b;i<=6;i++)
				s[(flag+1)%2][i]=s[(flag+1)%2][i+1];
			}	
		}
		if(strcmp(c,"end")==0)
		flag++;
	}
	cnt=0;
	if(s[0][0].h<=0)
	printf("-1\n");
	else if(s[1][0].h<=0)
	printf("1\n");
	else printf("0\n");
	printf("%d\n",s[0][0].h);
	for(int i=1;i<=7;i++)
	{
		if(s[0][i].h>0)
		cnt++;
	}
	printf("%d ",cnt);
	for(int i=1;i<=cnt;i++)
	printf("%d ",s[0][i].h);
	printf("\n");
	cnt=0;
	printf("%d\n",s[1][0].h);
	for(int i=1;i<=7;i++)
	if(s[1][i].h>0)
	cnt++;
	printf("%d ",cnt);
	for(int i=1;i<=cnt;i++)
	printf("%d ",s[1][i].h);
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值