比赛 2024国庆练习2 评测结果 AAAAAAAAAAAAAWWWAWWW
题目名称 战棋 最终得分 70
用户昵称 wdsjl 运行时间 0.143 s
代码语言 C++ 内存使用 3.59 MiB
提交时间 2024-10-05 17:53:24
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;

int n,xx,AA,BB,CC;
int cnt_s,cnt_r;
int Getid(){ 
	return xx=(xx*AA+BB)%CC;
}

const int N = 200;

struct node{
	int gong,sheng;
	char zhong;//鱼人 (”M”,Murloc),要么是海盗 (”P”,Pirate)
	char shu;//
}s[N],r[N],chu_s[N],chu_r[N];

int pos_s,pos_r;
int al_s[N],al_r[N];

struct node1{
	int L;
	int K;
	int C;
	int G;
}s_s,s_r;//统计阵营中各个属性的数量 

void init(){
	cnt_s=cnt_r=n;
	s_s={0,0,0,0};
	s_r={0,0,0,0};
	for(int i=0;i<n;i++){
		s[i]=chu_s[i];
		r[i]=chu_r[i];
		al_s[i]=0;
		al_r[i]=0;
		if(s[i].shu=='L')s_s.L++;
		else if(s[i].shu=='K')s_s.K++;
		else if(s[i].shu=='C')s_s.C++;
		else if(s[i].shu=='G')s_s.G++;
		if(r[i].shu=='L')s_r.L++;
		else if(r[i].shu=='K')s_r.K++;
		else if(r[i].shu=='C')s_r.C++;
		else if(r[i].shu=='G')s_r.G++;
	}
}

int main(){
	freopen("chess.in","r",stdin);
	freopen("chess.out","w",stdout);
	scanf("%d%d%d%d%d",&n,&xx,&AA,&BB,&CC);
	for(int i=0;i<n;i++){
		cin>>chu_s[i].gong>>chu_s[i].sheng;
		cin>>chu_s[i].zhong>>chu_s[i].shu;
	} 
	for(int i=0;i<n;i++){
		cin>>chu_r[i].gong>>chu_r[i].sheng;
		cin>>chu_r[i].zhong>>chu_r[i].shu;
	} 
	int res_s=0,res_r=0;
	for(int lun=1;lun<=500;lun++){
//		cout<<lun<<"轮"<<endl; 
		init();
		for(int i=0;i<n;i++){//鱼人领军 
			if(s[i].zhong=='M')s[i].gong+=20*s_s.L;
			if(s[i].shu=='L'&&s[i].zhong=='M')s[i].gong-=20;
			if(r[i].zhong=='M')r[i].gong+=20*s_r.L;
			if(r[i].shu=='L'&&r[i].zhong=='M')r[i].gong-=20;
		}
		while(cnt_s&&cnt_r){
			int x,y;
			x=Getid();
			y=Getid();
			pos_s=x%cnt_s;
			pos_r=y%cnt_r;
//			cout<<"POS"<<pos_s<<" "<<pos_r<<endl; 
			int a_s,a_r,tt=0;
			for(int i=0;i<n;i++){
				if(tt==pos_s&&al_s[i]==0){
					a_s=i;
					break;
				}
				if(al_s[i]==0)tt++;
			}
			tt=0;
			for(int i=0;i<n;i++){
				if(tt==pos_r&&al_r[i]==0){
					a_r=i;
					break;
				}
				if(al_r[i]==0)tt++;
			}//找到选中的两个棋子 
//			cout<<"weizhi"<<a_s<<" "<<a_r<<endl;
			if(s[a_s].zhong=='P'){//海盗队长 
				s[a_s].gong+=20*s_s.C;
				s[a_s].sheng+=20*s_s.C;
				if(s[a_s].shu=='C'){
					s[a_s].gong-=20;
					s[a_s].sheng-=20;
				} 
			}
			if(r[a_r].zhong=='P'){
				r[a_r].gong+=20*s_r.C;
				r[a_r].sheng+=20*s_r.C; 
				if(r[a_r].shu=='C'){
					r[a_r].gong-=20;
					r[a_r].sheng-=20;
				} 
			}
//			cout<<a_s<<" "<<a_r<<endl;
//			cout<<"qian shengming"<<s[a_s].gong<<' '<<s[a_s].sheng<<" "<<r[a_r].gong<<" "<<r[a_r].sheng<<endl; 
			s[a_s].sheng-=r[a_r].gong;
			r[a_r].sheng-=s[a_s].gong;
//			cout<<"shengming"<<s[a_s].sheng<<' '<<r[a_r].sheng<<endl;
			if(s[a_s].sheng<=0){
				if(s[a_s].shu=='L')s_s.L--;
				else if(s[a_s].shu=='K')s_s.K--;
				else if(s[a_s].shu=='C')s_s.C--;
				else if(s[a_s].shu=='G')s_s.G--;
				al_s[a_s]=1;
				cnt_s--;
				if(s[a_s].shu=='K'){
					for(int i=0;i<n;i++){
						if(s[i].zhong=='M'&&al_s[i]==0)s[i].gong+=20,s[i].sheng+=20;
					}
				}else if(s[a_s].zhong=='P'){
					for(int i=0;i<n;i++){
						if(s[i].shu=='G'&&al_s[i]==0)s[i].gong+=50;
					}
				}else if(s[a_s].shu=='L'){
					for(int i=0;i<n;i++){
						if(s[i].zhong=='M'&&al_s[i]==0)s[i].gong-=20;
					}
				}
			}
			if(r[a_r].sheng<=0){
				if(r[a_r].shu=='L')s_r.L--;
				else if(r[a_r].shu=='K')s_r.K--;
				else if(r[a_r].shu=='C')s_r.C--;
				else if(r[a_r].shu=='G')s_r.G--;
				al_r[a_r]=1;
				cnt_r--;
				if(r[a_r].shu=='K'){
					for(int i=0;i<n;i++){
						if(r[i].zhong=='M'&&al_r[i]==0)r[i].gong+=20,r[i].sheng+=20;
					}
				}else if(r[a_r].zhong=='P'){
					for(int i=0;i<n;i++){
						if(r[i].shu=='G'&&al_r[i]==0)r[i].gong+=50;
					}
				}else if(r[a_r].shu=='L'){
					for(int i=0;i<n;i++){
						if(r[i].zhong=='M'&&al_r[i]==0)r[i].gong-=20;
					}
				}
			}
		}
//		cout<<"!!!";
//		for(int i=0;i<n;i++)cout<<r[i].sheng<<" ";
//		cout<<endl;
//		cout<<cnt_s<<" "<<cnt_r<<endl;
		res_s+=cnt_s;
		res_r+=cnt_r; 
	}
	printf("%d %d",res_s,res_r);
	return 0;
}