zgjz3u8633 @ 2024-10-27 11:54:32
rt
直接模拟
by STEAMZzR01024602 @ 2024-10-27 12:10:07
题目都给那么详细了直接照着题目模拟就行了啊
by liu_zheng @ 2024-10-27 12:21:21
@STEAMZzR01024602 具体代码
by zgjz3u8633 @ 2024-10-27 14:39:14
@liu_zheng 我这里有
#include <bits/stdc++.h>
using namespace std;
bool vis[1005][1005];
char c[1005][1005];
int main()
{
int T;
cin>>T;
while(T--)
{
memset(vis,0,sizeof(vis));
int n,m,k;
cin>>n>>m>>k;
int x,y,d;
cin>>x>>y>>d;
int ans = 1;
int nx = x;
int ny = y;
vis[nx][ny]=1;
for(int i = 1;i<=n;i++)
{
cin>>c[i]+1;
}
for(int i = 1;i<=k;i++)
{
if(d==0)
{
ny++;
}
else if(d==1)
{
nx++;
}
else if(d==2)
{
ny--;
}
else if(d==3)
{
nx--;
}
if(nx>=1&&nx<=n&&ny>=1&&ny<=m&&c[nx][ny]=='.')
{
}
else
{
if(d==0)
{
ny--;
}
else if(d==1)
{
nx--;
}
else if(d==2)
{
ny++;
}
else if(d==3)
{
nx++;
}
d=(d+1)%4;
continue;
}
if(!vis[nx][ny]) ans++;
vis[nx][ny]=1;
}
cout<<ans<<"\n";
}
return 0;
}