赛时带马,当时样例全过,但现在测只有60,求助!!!
查看原帖
赛时带马,当时样例全过,但现在测只有60,求助!!!
1080056
ShenShi_Yan楼主2024/10/26 18:54
#include<bits/stdc++.h>
using namespace std;
char mp[1025][1025];
bool lxl[1025][1025];
int main(){
	short t;
	scanf("%hd",&t);
	while(t--){
		short n,m,x,y,d;
		int k;
		scanf("%hd%hd%d%hd%hd%hd",&n,&m,&k,&x,&y,&d);
		for(register int i=1;i<=n;++i){for(register int j=1;j<=m;++j){cin>>mp[i][j];}}
		memset(lxl,0,sizeof(lxl));
		lxl[x][y]=1;
		int cnt=1;
		for(register int i=0;i<k;++i){
			if(d==0){
				if(mp[x][y+1]=='.'){
					y++;
					if(lxl[x][y]==0){cnt++,lxl[x][y]=1;}
				}
				else d++;
			}
			else if(d==1){
				if(mp[x+1][y]=='.'){
					x++;
					if(lxl[x][y]==0){cnt++,lxl[x][y]=1;}
				}
				else d++;
			}
			else if(d==2){
				if(mp[x][y-1]=='.'){
					y--;
					if(lxl[x][y]==0){cnt++,lxl[x][y]=1;}
				}
				else d++;
			}
			else{
				if(mp[x-1][y]=='.'){
					x--;
					if(lxl[x][y]==0){cnt++,lxl[x][y]=1;}
				}
				else d=0;
			}
		}
		cout<<cnt<<"\n";
	}
	return 0;
}
2024/10/26 18:54
加载中...