#include <iostream>
#include <cstring>
using namespace std;
string map[1005];
bool bef[1005][1005];
int main() {
int T;
scanf("%d",&T);
while(T-- != 0) {
memset(bef, false, sizeof(bef));
int n,m,k,x,y,d,ans = 0;
scanf("%d%d%d%d%d%d",&n,&m,&k,&x,&y,&d);
--x;
--y;
cin.tie(nullptr) -> ios::sync_with_stdio(false);
for(int i = 0; i < n; ++i) {
cin >> map[i];
}
cin.tie(0) -> ios::sync_with_stdio(true);
while(k-- != 0) {
if(bef[x][y] == false) {
++ans;
}
bef[x][y] = true;
if(d == 0) {
if(y < m - 1 && map[x][y + 1] == '.') {
++y;
}
else {
d = (d + 1) & 3;
}
}
else if(d == 1) {
if(x < n - 1 && map[x + 1][y] == '.') {
++x;
}
else {
d = (d + 1) & 3;
}
}
else if(d == 2) {
if(y > 0 && map[x][y - 1] == '.') {
--y;
}
else {
d = (d + 1) & 3;
}
}
else {
if(x > 0 && map[x - 1][y] == '.') {
--x;
}
else {
d = (d + 1) & 3;
}
}
}
if(bef[x][y] == false) {
++ans;
}
printf("%d\n",ans);
}
return 0;
}
在
for(int i = 0; i < n; ++i) {
cin >> map[i];
}
这一段代码运行时不知道问什么输入会出现问题(好像是i≤10时?)