0pts,求调
查看原帖
0pts,求调
1066369
comradery楼主2024/8/3 14:25
#include <bits/stdc++.h>
using namespace std;
int n,m,curcpig=1;
int ontheworld_fp;
int restrank=-1;
char queuecard[2005];
bool clear_markpig;
struct pig
{
	int front;
	int next;
	int charactor;
	//1 huashang
	// 2 old man
	//3 zhimeishuyan
	bool znv;
	int hp;
	int zhumopaishu;
	int noyescharactor;
	bool ontheworld;
	char zhumopailei[111];
	bool zhumodebuyaode[111];
}p[15];
void  looklookpig (int smallpig)
{
	char zhenshi__xujia__shenfen[5];
	cin>>zhenshi__xujia__shenfen;
	if(zhenshi__xujia__shenfen[0]=='M')
	{
		p[smallpig].charactor=0;
		p[smallpig].noyescharactor=1;
	}
	else if(zhenshi__xujia__shenfen[0]=='Z')
	{
		p[smallpig].charactor=1;
	}
	else
	{
		p[smallpig].charactor=2;
		ontheworld_fp++;
	}
}
void zhu_de_ni_tian_shen_fen(int smallpig)
{
	looklookpig(smallpig);
	zhu_de_ni_tian_shen_fen(smallpig);
	if(smallpig==1) 
    p[smallpig].front=n;
    else
    p[smallpig].front=smallpig-1;
    if(smallpig==n)
    p[smallpig].next=1;
    else 
	p[smallpig].next=smallpig+1;
	p[smallpig].ontheworld=true;
	p[smallpig].hp=4;
}
void speakspeakpigdefrist(int  smallpig)
{
	char zhenshi__xujia__shenfen[5];
	for(int i=1;i<=4;i++)
	{
		cin>>zhenshi__xujia__shenfen[5];
		p[smallpig].zhumopaishu++;
		p[smallpig].zhumopailei[i]=zhenshi__xujia__shenfen[0];
	}
}
void speakspeakpig()
{
	for(int i=1;i<=m;i++)
    {
       char zhenshi__xujia__shenfen[5];
       cin>>zhenshi__xujia__shenfen;
       queuecard[i]=zhenshi__xujia__shenfen[0];
    }
}
void dechipai(int smallpig)
{
	p[smallpig].zhumopailei[++p[smallpig].zhumopaishu]=queuecard[curcpig];
	if(curcpig!=m)
	{
		curcpig++;
	}
}
bool peach(int smallpig)
{
	if(p[smallpig].hp<4)
	{
		p[smallpig].hp++;
		return true;
	}
	else 
	{
		return false;
	}
}
bool zhugeliannu(int smallpig)
{
	p[smallpig].znv=true;
	return true;
}
void shanxian(int smallpig)
{
	bool shanxian1=false;
    for(int i=1;i<=p[smallpig].zhumopaishu;i++)
    if(p[smallpig].zhumopailei[i]=='D'&&p[smallpig].zhumodebuyaode[i]==false)
    {
        shanxian1=true;
        p[smallpig].zhumodebuyaode[i]=true;
        break;
    }
    if(!shanxian1)
	{
		p[smallpig].hp--;
	}
}
void wasdead(int smallpig,int hunter)
{
	for(int i=1;i<=p[smallpig].zhumopaishu;i++)
	{
		if(p[smallpig].zhumopailei[i]=='P'&&p[smallpig].zhumodebuyaode[i]==false)
		{
			p[smallpig].hp++;
			p[smallpig].zhumodebuyaode[i]=true;
			if(p[smallpig].hp>0)
			{
				return ;
			}
		}
	}
	p[smallpig].ontheworld=false;
	p[p[smallpig].front].next=p[smallpig].next;
	p[p[smallpig].next].front=p[smallpig].front;
	if(p[smallpig].charactor==0)
	{
		restrank=1;
		return ;
	}
	if(p[smallpig].charactor==2)
	{
		ontheworld_fp--;
		if(ontheworld_fp==0)
		{
			restrank=0;
			return ;
		 } 
		dechipai(hunter);
		dechipai(hunter);
		dechipai(hunter);
	}
	else if(p[smallpig].charactor==1&&hunter==1)
	{
		p[1].zhumopaishu=0;
		memset(p[1].zhumopailei,0,sizeof(p[1].zhumopailei));
		memset(p[1].zhumodebuyaode,false,sizeof(p[1].zhumodebuyaode));
		p[1].znv=false;
		clear_markpig=true;
	}
}
bool kill(int smallpig)
{
	if(p[smallpig].charactor==2)
	{
		if(p[p[smallpig].next].noyescharactor==1&&p[p[smallpig].next].charactor==1||p[p[smallpig].next].charactor==0)
		{
			p[smallpig].noyescharactor=1;
			shanxian(p[smallpig].next);
			if(p[p[smallpig].next].hp<=0)
			{
				wasdead(p[smallpig].next,smallpig);
			}
			return true;
		}
	 }
	 else if(p[smallpig].charactor==1)
	 {
	 	if(p[p[smallpig].next].noyescharactor==1&&p[p[smallpig].next].charactor==2)
	 	{
	 		p[smallpig].noyescharactor=1;
	 		shanxian(p[smallpig].next);
	 		if(p[p[smallpig].next].hp<=0)
	 		{
	 			wasdead(p[smallpig].next,smallpig);
			 }
			return true;
		 }
	  } 
	  else
	  {
	  	if(p[p[smallpig].next].noyescharactor==2||p[p[smallpig].next].noyescharactor&&p[p[smallpig].next].charactor==2)
	  	{
	  		shanxian(p[smallpig].next);
	  		if(p[p[smallpig].next].hp<=0)
	  		{
	  			wasdead(p[smallpig].next,smallpig);
			  }
			  return true;
		  }
	  }
	  return false;
}
bool wujijikeji(int bigpig,int smallpig)
{
	int curpp=bigpig;
	do
	{
		if(p[curpp].charactor!=2&&smallpig==1)
		{
			for(int i=1;i<=p[curpp].zhumopaishu;i++)
			{
				if(p[curpp].zhumopailei[i]=='J'&&p[curpp].zhumodebuyaode[i]==false)
				{
					p[curpp].zhumodebuyaode[i]=true;
					if(p[curpp].noyescharactor!=1)
					{
						p[curpp].noyescharactor=1;
					}
					return !wujijikeji(curpp,2);
				}
			}
        }
        if(p[curpp].charactor==2&&smallpig==2)
        {
        	for(int i=1;i<=p[curpp].zhumopaishu;i++)
			{
				if(p[curpp].zhumopailei[i]=='J'&&p[curpp].zhumodebuyaode[i]==false)
				{
					p[curpp].zhumodebuyaode[i]=true;
					if(p[curpp].noyescharactor!=1)
					{
						p[curpp].noyescharactor=1;
					}
					return !wujijikeji(curpp,1);
				}
			}
		}
		curpp=p[curpp].next;
	}while(curpp!=bigpig);
	return false;
}
bool xiaojibananpigrenqing(int smallpig)
{
	for(int i=p[smallpig].next;i!=smallpig;i=p[i].next)
	{
		bool killer=false;
		if(p[i].noyescharactor==1)
		{
			if(wujijikeji(smallpig,p[i].charactor==0?1:p[i].charactor))
			{
				continue;
			}
		}
		for(int j=1;j<=p[i].zhumopaishu;j++)
		{
			if(p[i].zhumopailei[j]=='K'&&p[i].zhumodebuyaode[j]==false)
			{
				p[i].zhumodebuyaode[j]=true;
				killer=true;
				break;
			}
		}
		if(!killer)
		{
			p[i].hp--;
			if(p[i].hp<=0)
			{
				wasdead(i,smallpig);
			}
			if(i==1&&p[smallpig].noyescharactor==0)
			{
				p[smallpig].noyescharactor=2;
			}
			if(restrank!=-1)
			{
				return true;
			}
		}
	}
	return true; 
}
void putss()
{
	if(restrank==0)
	{
		cout<<"MP"<<endl;
	}
	else
	{
		cout<<"FP"<<endl;
	}
	for(int i=1;i<=n;i++)
	{
		if(!p[i].ontheworld)
		{
			cout<<"DEAD"<<endl;
			continue; 
		}
		for(int j=1;j<=p[i].zhumopaishu;j++)
		{
			if(!p[i].zhumodebuyaode[j])
			{
				cout<<p[i].zhumopailei[j]<<" ";
			}
		}
    }   
}
void battle(int attacker,int defender)
{
	if(attacker==1&&p[defender].charactor==1)
    {
     p[defender].hp--;
     if(p[defender].hp<=0)
	 {
	 	wasdead(defender,attacker);
	 }
     return;
     }
     int curp=defender;
     while(1)
     {
     bool flag=false;
     for(int i=1;i<=p[curp].zhumopaishu;i++)
     {
      if(p[curp].zhumopailei[i]=='K'&&p[curp].zhumodebuyaode[i]==false)
     {
      p[curp].zhumodebuyaode[i]=true;
      flag=true;
      break;
     }
	 }
     if(flag)curp=(curp==defender?attacker:defender);
     else
     {
      p[curp].hp--;
      if(p[curp].hp<=0)
	  {
	  	wasdead(curp,attacker==curp?defender:attacker);
	  }
      return;
      }
     }
}
bool fight(int smallpig)
{
	if(p[smallpig].charactor==2)
	{
		p[smallpig].noyescharactor=1;
		bool flag=wujijikeji(smallpig,1);
		if(!flag)
		{
			battle(smallpig,1);
		}
		return true;
	}
	else if(p[smallpig].charactor==1)
	{
		for(int i=p[smallpig].next;i!=smallpig;i=p[i].next)
		{
			if(p[i].noyescharactor==1&&p[i].charactor==2)
			{
				p[smallpig].noyescharactor=1;
				bool flag=false;
				if(p[i].noyescharactor==1)
				{
					flag=wujijikeji(smallpig,2);
				}
				if(!flag)
				{
					battle(smallpig,1);
				}
				return true;
			}
		}
	}
	else
	{
		for(int i=p[smallpig].next;i!=smallpig;i=p[i].next)
		{
			if((p[i].noyescharactor==1&&p[i].charactor==2)||p[i].noyescharactor==2)
			{
				bool flag=false;
				if(p[i].noyescharactor==1)
				{
					flag=wujijikeji(smallpig,2);
				}
				if(!flag)
				{
					battle(1,i);
				}
				return true;
			}
		}
	}
	return false;
}
bool use_wjqf(int cur)
{
 for(int i=p[cur].next;i!=cur;i=p[i].next)
 {
  bool used_kill=false;
  if(p[i].noyescharactor==1)
   if(wujijikeji(cur,p[i].charactor==0?1:p[i].charactor))
   {
   	continue;
   }
  for(int j=1;j<=p[i].zhumopaishu;j++)
   if(p[i].zhumopailei[j]=='D'&&p[i].zhumodebuyaode[j]==false)
   {
    p[i].zhumodebuyaode[j]=true;
    used_kill=true;
    break;
   }
  if(!used_kill)
  {
   p[i].hp--;
   if(p[i].hp<=0)
   {
   wasdead(i,cur);
   }
   if(i==1&&p[cur].noyescharactor==0)
   {
   	p[cur].noyescharactor=2;
   }
   if(restrank!=-1)return true;
  }
 }
 return true;
}
int main()
{
 scanf("%d%d",&n,&m);
 for(int i=1;i<=n;i++)
  zhu_de_ni_tian_shen_fen(i);
  speakspeakpig();
 while(restrank==-1)
  for(int i=1;i<=n;i=p[i].next)
  {
   dechipai(i);
   dechipai(i);
   int use_kill_num=0;
   for(int j=1;j<=p[i].zhumopaishu;j++)
    if(!p[i].zhumodebuyaode[j])
    {
     bool is_used=false;
     if(p[i].zhumopailei[j]=='P')
	 {
	 is_used=peach(i);
     }
     else if(p[i].zhumopailei[j]=='K')
     {
      if(use_kill_num==0||p[i].znv)
	  {
	  	is_used=kill(i);
	  }
      if(is_used)
	  {
	  	use_kill_num++;
	  }
     }
     else if(p[i].zhumopailei[j]=='F')
	 {
	 	is_used=fight(i);
	 }
     else if(p[i].zhumopailei[j]=='Z')
	 {
	 	is_used=zhugeliannu(i);
	 }
     else if(p[i].zhumopailei[j]=='N')
	 {
	 is_used=xiaojibananpigrenqing(i);
     }
     else if(p[i].zhumopailei[j]=='W')
	 {
	 	is_used=use_wjqf(i);
	 }
     if(is_used)
     {
      if(i==1&&clear_markpig)
	  {
	  	clear_markpig=false;
	  }
	  else
	  {
	  	 p[i].zhumodebuyaode[j]=true;
	   }
      j=0;
     }
     if(!p[i].ontheworld)
	 {
	 break;
	 	}
     if(restrank!=-1)
	 {
	 	break;
	 }
    }
   if(restrank!=-1)
   {
   	break;
   }
   putss();
   return 0;                                                                                                                                                                                                                                                                                                                                                                                     
  }
}
//aaaaaaaaa
2024/8/3 14:25
加载中...