Bigtanks10 @ 2024-10-26 16:55:22
#include<bits/stdc++.h>
using namespace std;
int t,n,m,x,y,k,ans,d,st[1010][1010];
int dx[5] = {0,1,0,-1},
dy[5] = {1,0,-1,0};
char c[1010][1010];
void dfs(int x,int y,int cnt,int cx)
{
if(cnt == k)
{
return ;
}
for(int i = 0;i <= 3;i++)
{
int cx1 = (cx + i) % 4,xx = x + dx[cx1],yy = y + dy[cx1];
if(xx > 0 && xx <= n && yy > 0 && yy <= m && c[xx][yy] != 'x')
{
if(cnt + i + 1 > k)
{
break;
}
if(st[xx][yy] == 0)
{
ans++;
st[xx][yy] = 1;
dfs(xx,yy,cnt + i + 1,cx1);
st[xx][yy] = 0;
}
else
{
dfs(xx,yy,cnt + i + 1,cx1);
st[xx][yy] = 0;
}
break;
}
}
}
int main()
{
//freopen("explore5.in","r",stdin);
//freopen("explore5.out","w",stdout);
cin>>t;
for(int i = 1;i <= t;i++)
{
ans = 1;
cin>>n>>m>>k>>x>>y>>d;
for(int j = 1;j <= n;j++)
{
for(int k1 = 1;k1 <= m;k1++)
{
cin>>c[j][k1];
}
}
st[x][y] = 1;
dfs(x,y,0,d);
st[x][y] = 0;
cout<<ans<<"\n";
}
return 0;
}
提交记录
by Bigtanks10 @ 2024-10-26 16:56:18
是数据的问题吗?
by YG_King @ 2024-10-26 17:11:50
@Bigtanks10 是第五个没过吗大样例
by shx2011 @ 2024-10-26 17:17:49
@Bigtanks10 你猜他为什么是民间数据[doge]
by _HLB_ @ 2024-10-26 17:22:19
我也是从第5个点开始就WA
by Bigtanks10 @ 2024-10-26 21:06:17
@YG_King 是最后一个