Dz8897 @ 2024-11-05 21:57:53
//GZ-J00235
#include<bits/stdc++.h>
using namespace std;
int mp[10005][10005],mc[10005][10005];
int n=0,m=0,k=0,x=0,y=0,z=0,d=0,t=0,sum=0;
char ch;
int csh(){
for(int j=0;j<=n+10;j++)
for(int q=0;q<=m+10;q++){
mp[j][q]=0;mc[j][q]=0;
}
}
int yd(){
//mp[x][y]=2;
if(d==0){
if(mp[x][y+1]==1&&x>=1&&x<=n&&y>=1&&y<=m){y++;mc[x][y]=2;}
else d=(d+1)%4;
}
else if(d==1){
if(mp[x+1][y]==1&&x>=1&&x<=n&&y>=1&&y<=m) {x++;mc[x][y]=2;}
else d=(d+1)%4;
}
else if(d==2){//N
if(mp[x][y-1]==1&&x>=1&&x<=n&&y>=1&&y<=m) {y--;mc[x][y]=2;}
else d=(d+1)%4;
}
else if(d==3){
if(mp[x-1][y]==1&&x>=1&&x<=n&&y>=1&&y<=m) {x--;mc[x][y]=2;}
else d=(d+1)%4;
}
/*
if(d==0){
if(mp[x][y+1]==2&&x>=1&&x<=n&&y>=1&&y<=m) {y++;mp[x][y]=2;}
else d=(d+1)%4;
}
else if(d==1){
if(mp[x+1][y]==2&&x>=1&&x<=n&&y>=1&&y<=m) {x++;mp[x][y]=2;}
else d=(d+1)%4;
}
else if(d==2){
if(mp[x][y-1]==2&&x>=1&&x<=n&&y>=1&&y<=m) {y--;mp[x][y]=2;}
else d=(d+1)%4;
}
else if(d==3){
if(mp[x-1][y]==2&&x>=1&&x<=n&&y>=1&&y<=m) {x--;mp[x][y]=2;}
else d=(d+1)%4;
}*/
//cout<<"F"<<x<<" "<<y<<" "<<d<<endl;
mc[x][y]=2;
return 0;
}
int main(){
freopen("explore.in","r",stdin);
freopen("explore.out","w",stdout);
cin>>t;
for(int i=1;i<=t;i++){
n=0,m=0,k=0,x=0,y=0,z=0,d=0,sum=0;
cin>>n>>m>>k;
cin>>x>>y>>d;
csh();
mc[x][y]=2;
for(int j=1;j<=n;j++){
for(int q=1;q<=m;q++){
cin>>ch;
if(ch=='x') mp[j][q]=-1;
if(ch=='.') mp[j][q]=1;
}
}
for(int o=1;o<=k;o++){
yd();
}
for(int j=1;j<=n;j++){
for(int q=1;q<=m;q++){
if(mc[j][q]==2) sum++;
}
}
cout<<sum<<endl;
}
return 0;
}
/*
2
1 5 4
1 1 2
....x
5 5 20
1 1 0
.....
.xxx.
.x.x.
..xx.
x....
*/
by st2010 @ 2024-11-05 22:31:17
@ENJOY_AK 用差分可以过
by ENJOY_AK @ 2024-11-05 22:31:34
@st2010 有时候找不出来bug,重写是好办法(缺点就是费时间)
by st2010 @ 2024-11-05 22:32:37
@ENJOY_AK 互关一下
by st2010 @ 2024-11-05 22:33:40
@Dz8897 楼主人呢???
by ENJOY_AK @ 2024-11-05 22:37:25
@st2010 我打的暴力也过了,虽然看起来会tle(壶关)
by st2010 @ 2024-11-05 22:44:14
@ENJOY_AK CSP_J 220分广东几等
by ENJOY_AK @ 2024-11-05 22:46:21
@st2010 二等吧
by st2010 @ 2024-11-05 22:47:50
@ENJOY_AK 心轻轻的碎了
by fyc201908 @ 2024-11-06 10:01:31
去掉freopen,洛谷不支持
by fyc201908 @ 2024-11-06 10:02:17
@ENJOY_AK emmm...有道理