TangYouhang @ 2024-10-26 22:04:06
#include<iostream>
using namespace std;
int map[10005][10005];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main()
{
int n,m,T,k;
cin>>T;
for(int i=0;i<T;i++)
{
cin>>n>>m>>k;
int sx,sy,sd,ans=1;
cin>>sx>>sy>>sd;
for(int i=1;i<=n;i++)
{
string tmp;
cin>>tmp;
for(int j=0;j<m;j++)
{
if(tmp[j]=='.')map[i][j+1]=0;
if(tmp[j]=='x')map[i][j+1]=-1;
}
}
int cx=sx,cy=sy,cd=sd;
for(int j=0;j<k;j++)
{
if(cx+dx[cd]>0&&cy+dy[cd]>0&&cx+dx[cd]<=n&&cy+dy[cd]<=m&&map[cx+dx[cd]][cy+dy[cd]]>=0)
{
if(map[cx+dx[cd]][cy+dy[cd]]==0)
{
map[cx+dx[cd]][cy+dy[cd]]=1;
ans++;
cx+=dx[cd];
cy+=dy[cd];
}
}
else{
cd=(cd+1)%4;
}
}
cout<<ans<<endl;
}
}
by TangYouhang @ 2024-10-26 22:05:48
for(int i=0;i<T;i++) { i稍微改一下改成tmppp