85分,过了无限制数据,挂在了nmq<=100的数据
查看原帖
85分,过了无限制数据,挂在了nmq<=100的数据
168233
CSP_2020_qwq楼主2024/9/22 19:55
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
string s[505];
bool l[200050];
int aa[200050],f[200050];
int main() {
//	ios::sync_with_stdio(false);
//	cin.tie();cout.tie();
	int  n,m,q,k;
	cin>>n>>m>>q>>k;
	for(int i=0;i<n;i++) cin>>s[i];
	int sx=0,sy=0;
	int i=0;
	while(q--) {
		i++;
		char c;
		int a,b;
		cin>>c;
		cin>>a>>b;
		if(aa[i]>0) {
			aa[i]--;
			aa[i+k]=aa[i];
			l[i+k]^=l[i];
		}
		if(l[i]) {
			if(c=='U')sx+=a;
			if(c=='D')sx-=a;
			if(c=='L')sy+=a;
			if(c=='R')sy-=a;
		}
		else {
			if(c=='U')sx-=a;
			if(c=='D')sx+=a;
			if(c=='L')sy-=a;
			if(c=='R')sy+=a;
		}
		if(sx<0)sx=0;
		if(sy<0)sy=0;
		if(sx>=n)sx=n-1;
		if(sy>=m)sy=m-1;
		if(s[sx][sy]=='X')
			l[i+k]=0,l[i+k]^=(1^l[i]),aa[i+k]=max(b-1,aa[i+k]),f[i+b*k]++;
		if(f[i]) {
			l[i+k]^=(f[i]%2);
		}
	}
	cout<<sx+1<<" "<<sy+1<<endl; 
	return 0;
}

所以数据越大越水对吗(

2024/9/22 19:55
加载中...