jiang_shi_qi @ 2024-10-26 21:55:39
#include<bits/stdc++.h>
using namespace std;
char a[1010][1010];
bool b[1010][1010];
int n, m, k, x, y, d;
int main(){
freopen("explore.in", "r", stdin);
freopen("explore.out", "w", stdout);
int T;
cin >> T;
while(T--){
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];
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
b[i][j] = false;
}
}
b[x][y] = true;
while(k--){
if(d == 0){
if(x >= 1 and x <= n and y + 1 >= 1 and y + 1 <= m and a[x][y + 1] == '.'){
x = x;
y++;
}else{
d = (d + 1) % 4;
}
}else if(d == 1){
if(x + 1 >= 1 and x + 1 <= n and y >= 1 and y <= m and a[x + 1][y] == '.'){
x++;
y = y;
}else{
d = (d + 1) % 4;
}
}else if(d == 2){
if(x >= 1 and x <= n and y - 1 >= 1 and y - 1 <= m and a[x][y - 1] == '.'){
x = x;
y--;
}else{
d = (d + 1) % 4;
}
}else if(d == 3){
if(x - 1 >= 1 and x - 1 <= n and y >= 1 and y <= m and a[x - 1][y] == '.'){
x--;
y = y;
}else{
d = (d + 1) % 4;
}
}
b[x][y] = true;
}
int ans = 0;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(b[i][j]){
ans++;
}
}
}
cout << ans << endl;
}
return 0;
}
by linrun0504 @ 2024-10-26 21:56:21
@jiang_shi_qi
freopen为什么不删!!!
by jiang_shi_qi @ 2024-10-26 21:56:24
为什么我是0分??? 样例都过了
by zrl123456 @ 2024-10-26 21:56:34
luogu 上请去掉 freopen
by jiang_shi_qi @ 2024-10-26 22:09:24
谢谢各位大哥 已经删了 100AC