[CSP-J 2024] 地图探险
#include<iostream>
#include<cstring>
using namespace std;
char mp[1005][1005];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
ios::sync_with_stdio(false);
int t;
cin>>t;
while(t--){
int a,b,k;
int x,y,d;
cin>>a>>b>>k>>x>>y>>d;
x--,y--;
memset(mp,0,sizeof(mp));
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
cin>>mp[i][j];
}
}
mp[y][x]='v';
int sum=1;
while(k>0){
int tx=x+dx[d],ty=y+dy[d];
if(mp[ty][tx]=='.'){
x=tx,y=ty;
if(mp[ty][tx]!='v' && mp[ty][tx]=='.'){
sum++;
mp[ty][tx]='v';
}
}else{
d=(d+1)%4;
}
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
cout<<mp[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;
cout<<sum<<" ";
cout<<"d:"<<d<<" "<<ty+1<<" "<<tx+1<<endl;
k--;
}
cout<<sum<<endl;
}
return 0;
}
本蒟蒻求大佬改