样例过但0分,不道哪儿错,求调
查看原帖
样例过但0分,不道哪儿错,求调
1441391
Xu0120楼主2024/11/18 16:28
#include<bits/stdc++.h>
using namespace std;
int a,c,b,d,e[1005][1005],ans=0;
int x,y,d1;
char n;
int main(){
	cin>>a;
	for(int i=1;i<=a;i++){
		ans=0;
		cin>>c>>b>>d;
		cin>>x>>y>>d1;
		for(int u=1;u<=c;u++){
			for(int q=1;q<=b;q++){
				cin>>n;
				if(n=='.'){
					e[u][q]=1;
				}
				else{
					e[u][q]=0;
				}
			}
		}
		
		for(int i=1;i<=d;i++){
			if(d1==0){
				if(e[x][y+1]==0){
					d1++; 
				}
				else{
					ans++;
					e[x][y+1]==0;
					y+=1;
				}
			}
			else if(d1==1){
				if(e[x-1][y]==0){
					d1++; 
				}
				else{
					ans++;
					e[x-1][y]==0;
					x-=1;
				}
			}
			else if(d1==2){
				if(e[x][y+1]==0){
					d1++; 
				}
				else{
					ans++;
					e[x][y+1]==0;
					y+=1;
				}
			}
			else if(d1==3){
				if(e[x+1][y]==0){
					d1++; 
				}
				else{
					ans++;
					e[x+1][y]==0;
					x+=1;
				}
			}
			d1%=4;
		}cout<<ans<<endl;
	}
	
} 
2024/11/18 16:28
加载中...