玄学问题
查看原帖
玄学问题
756608
andy605楼主2024/12/8 11:39

大佬求调!

#include <bits/stdc++.h>
using namespace std;
bool a[1010][1010],s[1010][1010];
int t;
int cnt;
int x,y;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int m,n,d,k;
int main(){
	cin>>t;
	while(t--){
		
		memset(a,false,sizeof(a));
		memset(s,false,sizeof(s));
		cnt=0;
		scanf("%d%d%d\n%d%d%d",&m,&n,&k,&x,&y,&d);
		for(int i=1;i<=m;i++)
			for(int j=1;j<=n;j++)
				a[i][j]=(getchar()=='.'?true:false);
		s[x][y]=true;
		cnt++;
		while(k--){
			int xx=x+dx[d];
			int yy=y+dy[d];
			if(a[xx][yy]==1){
				x=xx;
				y=yy;
				if(!s[x][y]){
					s[x][y]=true;
					cnt++;
				}
			}
			else d=(d+1)%4;
		}
		printf("%d\n",cnt);
	}
}

第一次正常输入输出,结果正确 然后第二次在循环的时候,完美跳过了输入...... 求调,悬关QWQ!

2024/12/8 11:39
加载中...