longyitongxue @ 2024-10-28 22:41:40
题目
得分
我好不容易耗费非常久的
by longyitongxue @ 2024-10-28 22:52:53
#include<iostream>
#include<stdlib.h>
#include<string.h>
using namespace std;
int n,m,k,cnt;
char a[1005][1005];
bool vis[1005][1005];
int dx[4]= {0,1,0,-1};
int dy[4]= {1,0,-1,0};
void serch(int x,int y,int d)
{
while(k--)
{
int nx=x+dx[d];
int ny=y+dy[d];
if(a[nx][ny]=='.')
{
if(!vis[nx][ny])
{
vis[nx][ny]=1;
cnt++;
}
x=nx;
y=ny;
}
else
{
d=(d+1)%4;
}
}
cout<<cnt<<'\n';
}
int main()
{
int t;
cin>>t;
while(t--)
{
cnt=1;
int x,y,d;
memset(vis,0,sizeof(vis));
cin>>n>>m>>k>>x>>y>>d;
for(int i=1; i<=n; i++)
{
for(int j=1; j<=m; j++)
{
cin>>a[i][j];
}
}
serch(x,y,d);
}
return 0;
}
by tyr_04 @ 2024-10-28 23:11:56
@longyitongxue 边界?要判是否跑出地图吧
by longyitongxue @ 2024-10-29 21:25:07
@tyr_04 听我说谢谢你!(真诚的,不是那个意思)
by longyitongxue @ 2024-10-29 21:25:48
已关注,求关注! @tyr_04