35pts求助
查看原帖
35pts求助
1250410
zhaocs123456楼主2024/10/20 21:11
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#define ll long long
using namespace std;
bool p=0;
ll n,m,q,l,c[103][103],k,d[103],a[103],Re,Me,z,Ri,Mi,t[103],b[103];
int main(){
	//	freopen("a.in","r",stdin);
	//	freopen("a.out","w",stdout);
	scanf("%lld %lld %lld %lld",&n,&m,&q,&l);
	Re=Me=m;
	Ri=Mi=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=l;j++)
			scanf("%lld",&c[i][j]);
	for(int i=1;i<=n;i++)
		scanf("%lld",&d[i]);
	for(int oo=1;oo<=q;oo++){
//		cout<<oo<<endl;
		for(int i=1;i<=n;i++){
//			cout<<t[i]<<' '<<d[i]<<' '<<a[i]<<' '<<b[i]<<endl;
			if(t[i]==1)
				Re+=d[i];
			else if(t[i]==2)
				Me+=d[i];
		}
//		cout<<Ri<<' '<<Re<<' '<<Mi<<' '<<Me<<endl;
		if(!p)
			scanf("%lld%lld",&z,&k);
		p=0;
		for(int i=1;i<=k;i++){
			Ri++;
			if(Ri>n) Ri=Ri%n+1;
			if(t[Ri]==1) Re+=a[Ri];
			else Re-=a[Ri],Me+=a[Ri];
			if(Re<0){
				printf("Renko\n");
				return 0;
			}
		}
		
		scanf("%lld%lld",&z,&k);
		if(z==1){
			for(int i=1;i<=k;i++){
				Mi++;
				if(Mi>n) Mi=Mi%n+1;
				if(t[Mi]==2) Me+=a[Mi];
				else Me-=a[Mi],Re+=a[Mi];
				if(Me<0){
					printf("Merry\n");
					return 0;
				}
			}
			
			scanf("%lld%lld",&z,&k);
			if(z==1){
				p=1;
				continue;
			}else {
				if(t[Mi]==0){
					t[Mi]=2;
					for(int i=1;i<=k;i++){
						if(b[Mi]+1>l || Me<c[Mi][b[Mi]+1]) break;
						b[Mi]++;
						Me-=c[Mi][b[Mi]];
						a[Mi]+=c[Mi][b[Mi]];
					}
				}else if(t[Mi]==2){
					for(int i=1;i<=k;i++){
						if(b[Mi]+1>l || Me<c[Mi][b[Mi]+1]) break;
						b[Mi]++;
						Me-=c[Mi][b[Mi]];
						a[Mi]+=c[Mi][b[Mi]];
					}
				}
			}
		}else {
			if(t[Ri]==0){
				t[Ri]=1;
				for(int i=1;i<=k;i++){
					if(b[Ri]+1>l || Re<c[Ri][b[Ri]+1]) break;
					b[Ri]++;
					Re-=c[Ri][b[Ri]];
					a[Ri]+=c[Ri][b[Ri]];
				}
			}else if(t[Ri]==1){
				for(int i=1;i<=k;i++){
					if(b[Ri]+1>l || Re<c[Ri][b[Ri]+1]) break;
					b[Ri]++;
					Re-=c[Ri][b[Ri]];
					a[Ri]+=c[Ri][b[Ri]];
				}
			}
			scanf("%lld%lld",&z,&k);
			for(int i=1;i<=k;i++){
				Mi++;
				if(Mi>n) Mi=Mi%n+1;
				if(t[Mi]==2) Me+=a[Mi];
				else Me-=a[Mi],Re+=a[Mi];
				if(Me<0){
					printf("Merry\n");
					return 0;
				}
			}
			scanf("%lld%lld",&z,&k);
			if(z==1){
				p=1;
				continue;
			}else {
				if(t[Mi]==0){
					t[Mi]=2;
					for(int i=1;i<=k;i++){
						if(b[Mi]+1>l || Me<c[Mi][b[Mi]+1]) break;
						b[Mi]++;
						Me-=c[Mi][b[Mi]];
						a[Mi]+=c[Mi][b[Mi]];
					}
				}else if(t[Mi]==2){
					for(int i=1;i<=k;i++){
						if(b[Mi]+1>l || Me<c[Mi][b[Mi]+1]) break;
						b[Mi]++;
						Me-=c[Mi][b[Mi]];
						a[Mi]+=c[Mi][b[Mi]];
					}
				}
			}
		}
//		cout<<Re<<' '<<Me<<endl;
	}
//	cout<<Re<<' '<<Me<<endl;
	for(int i=1;i<=n;i++){
//		cout<<t[i]<<' '<<d[i]<<' '<<a[i]<<' '<<b[i]<<endl;
		if(t[i]==1)
			Re+=d[i];
		else if(t[i]==2)
			Me+=d[i];
	}
	cout<<Re<<' '<<Me<<endl;
	
	return 0;
}

其他全WA

2024/10/20 21:11
加载中...