比赛 2024国庆练习2 评测结果 AAAAAAAAAAAAAAAAAWWW
题目名称 战棋 最终得分 85
用户昵称 会挽弯弓满月 运行时间 0.163 s
代码语言 C++ 内存使用 3.57 MiB
提交时间 2024-10-05 17:39:58
显示代码纯文本
#include <bits/stdc++.h> 
#define ll long long
const int N=60;
using namespace std;
void read(int &x) 
{
	x=0;
	int f=1;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
	x*=f;
}
int n,xx,AA,BB,CC,n1,n2;
int Getid()
{
	return xx=(xx*AA+BB)%CC;
}
int x,y;
int T=500;
int gong,sheng;
int ans1,ans2;
char te,zhong;
vector <int> gonga,gonga1,shenga,shenga1;
vector <int> gongb,gongb1,shengb,shengb1;
vector <char> zhonga,zhonga1,tea,tea1;
vector <char> zhongb,zhongb1,teb,teb1;
void BUFF()
{
	for(int i=0;i<n;i++)
	{
		if(tea1[i]=='L')
		{
			for(int j=0;j<n;j++)
			{
				if(j==i) continue;
				if(zhonga1[j]=='M') gonga1[j]+=20;
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		if(teb1[i]=='L')
		{
			for(int j=0;j<n;j++)
			{
				if(j==i) continue;
				if(zhongb1[j]=='M') gongb1[j]+=20;
			}
		}
	}
}
void end()
{
	if(shenga[x]<=0)
	{
		//cout<<"ongqg\n";
		if(tea[x]=='L')
		{
			for(int j=0;j<n1;j++)
			{
				if(zhonga[j]=='M') gonga[j]-=20;
			}
		}
		if(tea[x]=='K')
		{
			for(int j=0;j<n1;j++)
			{
				if(zhonga1[j]=='M')
				{
					gonga[j]+=20;
					shenga[j]+=20;
				}
			}
		}
		if(zhonga[x]=='P')
		{
			for(int j=0;j<n1;j++)
			{
				if(tea[j]=='G') gonga[j]+=50;
			}
		}
		n1--;
		gonga.erase(gonga.begin()+x);
		shenga.erase(shenga.begin()+x);
		zhonga.erase(zhonga.begin()+x);
		tea.erase(tea.begin()+x);
	}
	if(shengb[y]<=0)
	{
		//cout<<"iogqweoqfqbv\n";
		if(teb[y]=='L')
		{
			for(int j=0;j<n2;j++)
			{
				if(zhongb[j]=='M') gongb[j]-=20;
			}
		}
		if(teb[y]=='K')
		{
			for(int j=0;j<n2;j++)
			{
				if(zhongb[j]=='M')
				{
					gongb[j]+=20;
					shengb[j]+=20;
				}
			}
		}
		if(zhongb[y]=='P')
		{
			for(int j=0;j<n2;j++)
			{
				if(teb[j]=='G') gongb[j]+=50;
			}
		}
		n2--;
		gongb.erase(gongb.begin()+y);
		shengb.erase(shengb.begin()+y);
		zhongb.erase(zhongb.begin()+y);
		teb.erase(teb.begin()+y);
	}
}
void init()
{
	gonga=gonga1;
	shenga=shenga1;
	zhonga=zhonga1;
	tea=tea1;
	n1=n;
	gongb=gongb1;
	shengb=shengb1;
	zhongb=zhongb1;
	teb=teb1;
	n2=n;
}
void CCC()
{
	if(zhonga[x]=='P')
	{
		for(int i=0;i<n1;i++)
		{
			if(tea[i]=='C'&&i!=x)
			{
				gonga[x]+=20;
				shenga[x]+=20;
			}
		}
	}
	if(zhongb[y]=='P')
	{
		for(int i=0;i<n2;i++)
		{
			if(teb[i]=='C'&&i!=y)
			{
				gongb[y]+=20;
				shengb[y]+=20;
			}
		}
	}
	
}
void xy()
{
	x=Getid();
	//printf("%d ",xx);
	//printf("x=%d n1=%d ",x,n1);
	x%=n1;
	//printf("%d\n",x);
	y=Getid();
	//printf("%d\n",xx);
	y%=n2;
}
int main()
{
	freopen("chess.in","r",stdin);
	freopen("chess.out","w",stdout);
	read(n);read(xx);read(AA);read(BB);read(CC);
	//cout<<xx<<" "<<AA<<" "<<BB<<" "<<CC<<endl;
	for(int i=1;i<=n;i++)
	{
		read(gong);read(sheng);
		scanf("%c %c",&zhong,&te);
		gonga1.push_back(gong);
		shenga1.push_back(sheng);
		zhonga1.push_back(zhong);
		tea1.push_back(te);
	}
	for(int i=1;i<=n;i++)
	{
		read(gong);read(sheng);
		scanf("%c %c",&zhong,&te);
		gongb1.push_back(gong);
		shengb1.push_back(sheng);
		zhongb1.push_back(zhong);
		teb1.push_back(te);
	}
	/*
	n1=n2=n;
	for(int i=0;i<n1;i++)
	{
		cout<<gonga1[i]<<" "<<shenga1[i]<<" "<<zhonga1[i]<<" "<<tea1[i]<<endl;
	}
	for(int i=0;i<n2;i++)
	{
		cout<<gongb1[i]<<" "<<shengb1[i]<<" "<<zhongb1[i]<<" "<<teb1[i]<<endl;
	}
	putchar('\n');
	*/
	BUFF();
	while(T--)
	{
		
		init();
		while(n1&&n2)
		{
			xy();
			
			//printf("%lld %lld\n",x,y);
			CCC();
			//printf("%lld %lld\n",gonga[x],shenga[x]);
			//printf("%lld %lld\n\n",gongb[y],shengb[y]);
			shenga[x]-=gongb[y];
			shengb[y]-=gonga[x];
			end();
			//cout<<n1<<" "<<n2<<endl;
		}
		//cout<<n1<<" "<<n2<<endl;
		ans1+=n1;
		ans2+=n2;
	}
	printf("%d %d",ans1,ans2);
	
	return 0;
}