oZHZo @ 2024-11-10 23:20:27
#include <bits/stdc++.h>
using namespace std;
int main()
{
int T;
char a[1001][1001];
bool b[1001][1001];
int n[6], m[6], k[6];
int x[6], y[6], d[6];
int cnt[6];
cin >> T;
for(int i = 0; i < T; i++)
{
cin >> n[i] >> m[i] >> k[i];
cin >> x[i] >> y[i] >> d[i];
for(int j = 0; j < n[i]; j++)
{
for(int c = 0; c < m[i]; c++)
{
cin >> a[j][c];
b[j][c] == false;
}
}
cnt[i] = 1;
}
for(int i = 0; i < T; i++)
{
memset(b, 0, sizeof(b));
x[i]--;
y[i]--;
b[x[i]][y[i]] = true;
while(k[i] > 0)
{
d[i] = d[i]%4;
if(d[i] == 0 && a[x[i]][y[i]+1] == '.')
{
y[i]++;
if(b[x[i]][y[i]] == false)
{
cnt[i]++;
b[x[i]][y[i]] = true;
}
k[i]--;
continue;
}
if(d[i] == 1 && a[x[i]+1][y[i]] == '.')
{
x[i]++;
if(b[x[i]][y[i]] == false)
{
cnt[i]++;
b[x[i]][y[i]] = true;
}
k[i]--;
continue;
}
if(d[i] == 2 && a[x[i]][y[i]-1] == '.')
{
y[i]--;
if(b[x[i]][y[i]] == false)
{
cnt[i]++;
b[x[i]][y[i]] = true;
}
k[i]--;
continue;
}
if(d[i] == 3 && a[x[i]-1][y[i]] == '.')
{
x[i]--;
if(b[x[i]][y[i]] == false)
{
cnt[i]++;
b[x[i]][y[i]] = true;
}
k[i]--;
continue;
}
else
{
d[i]++;
k[i]--;
continue;
}
}
cout << cnt[i] << endl;
}
return 0;
}
这么晚了能有大佬救我吗(悲)