求救!!!样例过不了!!
查看原帖
求救!!!样例过不了!!
736027
zhouchenrui楼主2024/11/2 11:13
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+10;
char a[N][N];
int main(){
	bool vis[N][N];
	int t;
	cin>>t;
	while(t--){
		int n,m,k;
		int x,y,d;
		cin>>n>>m>>k;
		cin>>x>>y>>d;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				cin>>a[i][j];
			}
		}
		int cnt=0;
		while(k>0){
			if(d==0){
				if(a[x][y+1]=='.'){
					if(vis[x][y+1]==true){
						cnt++;
						vis[x][y+1]==false;
						k--;
					}else{
						k--;
					}
				}else{
					d=1;
				}
			}
			if(d==1){
				if(a[x+1][y]=='.'){
					if(vis[x+1][y]==true){
						cnt++;
						vis[x+1][y]==false;
						k--;
					}
					else{
						k--;
					}
				}else{
					d=2;
				}
			}
			if(d==2){
				if(a[x][y-1]=='.'){
					if(vis[x][y-1]==true){
						cnt++;
						vis[x][y-1]==false;
					}
				k--;
				}else{
					d=3;
				}
			}
			if(d==3){
				if(a[x-1][y]=='.'){
					if(vis[x-1][y]==true){
						cnt++;
						vis[x-1][y]==false;
						k--;
					}
					else{
						k--; 
					} 
				}else{
					d=0;
				}
			}
		}
		cout<<cnt<<endl;
	}
	return 0;
}
2024/11/2 11:13
加载中...