wuyouawa @ 2024-10-26 16:10:29
rt。
代码
by YUQI_George @ 2024-10-26 17:37:17
我也是
#include<iostream>
using namespace std;
typedef long long ll;
const int N=1e3+10;
ll s;
ll n,m,k,x,y,d;
bool f[N][N];
char a[N][N];
int fx[4]={0,1,0,-1};
int fy[4]={1,0,-1,0};
ll cnt;
void dfs(ll x,ll y,ll pos,ll d){
f[x][y]=1;
if(pos==k){
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(f[i][j]==1) cnt++;
}
}
cout<<cnt<<endl;
return;
}
ll tx=x+fx[d];
ll ty=y+fy[d];
if(x>=1&&x<=n&&y>=1&&y<=m&&a[tx][ty]=='.'){
dfs(tx,ty,pos+1,d);
}else{
if(d==3){
dfs(x,y,pos+1,0);
}else{
dfs(x,y,pos+1,d+1);
}
}
}
int main(){
ios::sync_with_stdio(0);
cin>>s;
while(s--){
cin>>n>>m>>k>>x>>y>>d;
cnt=0;
memset(f,0,sizeof(f));
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
}
}
dfs(x,y,0,d);
}
return 0;
}
by xxJoy0420 @ 2024-10-27 12:46:35
你为什么用搜索?大模拟不香吗???
by wuyouawa @ 2024-10-27 15:24:31
@xxJoy0420 哎呀,考场脑崩了
by wuyouawa @ 2024-10-27 15:25:01
thx.,调好了,此帖结