a18602930307 @ 2024-11-04 21:25:44
#include<bits/stdc++.h>
using namespace std;
char t[1100][1100];
long long int vis[1100][1100];
long long int n,m,k,x0,yyy,b0,ans=1,T;
int main(){
//freopen("explore.in","r",stdin);
//freopen("explore.out","w",stdout);
cin>>T;
for(int pp=1;pp<=T;pp++){
cin>>n>>m>>k;
cin>>x0>>yyy>>b0;
vis[x0][yyy]=1;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>t[i][j];
}
}
for(int i=1;i<=k;i++){
int xx,yy;
if(b0==0){xx=x0;yy=yyy+1;}
if(b0==1){xx=x0+1;yy=yyy;}
if(b0==2){xx=x0;yy=yyy-1;}
if(b0==3){xx=x0-1;yy=yyy;}
if(((xx>=1&&xx<=n)&&(yy>=1&&yy<=m))&&t[xx][yy]=='.'){
if(vis[xx][yy]==0)ans++,vis[xx][yy]=1;
x0=xx;yyy=yy;
}else{
b0=(b0+1)%4;
}
}
cout<<ans<<endl;
}
return 0;
}
by LionBlaze @ 2024-11-04 21:31:45
@a18602930307 多测不清空,爆零两行泪。
by a18602930307 @ 2024-11-04 21:36:33
@LionBlaze 还没有分
#include<bits/stdc++.h>
using namespace std;
char t[1100][1100];
long long int vis[1100][1100];
long long int n,m,k,x0,yyy,b0,ans=1,T;
int main(){
//freopen("explore.in","r",stdin);
//freopen("explore.out","w",stdout);
cin>>T;
for(int pp=1;pp<=T;pp++){
ans=0;
memset(t,0,sizeof(t));
memset(vis,0,sizeof(vis));
cin>>n>>m>>k;
cin>>x0>>yyy>>b0;
vis[x0][yyy]=1;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>t[i][j];
}
}
for(int i=1;i<=k;i++){
int xx,yy;
if(b0==0){xx=x0;yy=yyy+1;}
if(b0==1){xx=x0+1;yy=yyy;}
if(b0==2){xx=x0;yy=yyy-1;}
if(b0==3){xx=x0-1;yy=yyy;}
if(((xx>=1&&xx<=n)&&(yy>=1&&yy<=m))&&t[xx][yy]=='.'){
if(vis[xx][yy]==0)ans++,vis[xx][yy]=1;
x0=xx;yyy=yy;
}else{
b0=(b0+1)%4;
}
}
cout<<ans<<endl;
}
return 0;
}
by a18602930307 @ 2024-11-04 21:48:10
@LionBlaze %%%