yuxinrui0618 @ 2024-11-05 16:58:52
#include<bits/stdc++.h>
using namespace std;
char a[1004][1004];
int b[1004][1004];
int main(){
int t;
cin>>t;
while (t--)
{
memset(b,0,sizeof(b));
int n,m,k,x,y,z,c=1;
cin>>n>>m>>k;
cin>>x>>y>>z;
for (int i=1;i<=n;i++)
for (int j=1;j<=m;j++)
cin>>a[i][j];
int nx=x,ny=y,nz=z;
for (int i=1;i<=k;i++)
{
if (nz==0)
{
if (a[nx][ny+1]=='.' && ny+1<=m)
{
ny++;
if (b[nx][ny]==0)
c++,b[nx][ny]=1;
}
else
nz=(nz+1)%4;
}
else if (nz==1)
{
if (a[nx+1][ny]=='.' && nx+1<=n)
{
nx++;
if (b[nx][ny]==0)
c++,b[nx][ny]=1;
}
else
nz=(nz+1)%4;
}
else if (nz==2)
{
if (a[nx][ny-1]=='.' && ny-1>=1)
{
ny--;
if (b[nx][ny]==0)
c++,b[nx][ny]=1;
}
else
nz=(nz+1)%4;
}
else
{
if (a[nx-1][ny]=='.' && nx-1>=1)
{
nx--;
if (b[nx][ny]==0)
c++,b[nx][ny]=1;
}
else
nz=(nz+1)%4;
}
}
cout<<c<<endl;
}
return 0;
}
这个程序其实大数据就没过,有时会少一
by q_hacker_p @ 2024-11-05 20:08:55
孩子,你无敌了。如果是这样呢,起点 -> (
by q_hacker_p @ 2024-11-05 20:09:24
@yuxinrui0618
by yuxinrui0618 @ 2024-11-05 20:24:30
@q_hacker_p 哦
by yuxinrui0618 @ 2024-11-05 20:28:36
@q_hacker_p 我就差那50就300了,估计就能稳省一