📄 1111.txt
字号:
//#define debug 1
#define NMAX 22
#define INF 1000000001
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int x,y,sty,stx;
char a[NMAX][NMAX];
bool check[NMAX][NMAX];
int xp[8]={0,1,0,-1,1,1,-1,-1},yp[8]={-1,0,1,0,-1,1,1,-1};
int ans;
void tr(int cy,int cx)
{
int i;
int ty,tx;
check[cy][cx]=1;
for(i=0;i<4;i++)
{
ty=cy+yp[i];
tx=cx+xp[i];
if(a[ty][tx]!='X')
ans++;
}
for(i=0;i<8;i++)
{
ty=cy+yp[i];
tx=cx+xp[i];
if(a[ty][tx]=='X'&&check[ty][tx]==0)
tr(ty,tx);
}
}
void solve()
{
ans=0;
memset(check,0,sizeof(check));
tr(sty,stx);
printf("%d\n",ans);
}
main()
{
#if _DEBUG
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
while(1)
{
scanf("%d%d%d%d\n",&y,&x,&sty,&stx);
if(y==0&&x==0)
break;
memset(a,0,sizeof(a));
for(int i=1;i<=y;i++)
gets(a[i]+1);
solve();
}
#if _DEBUG
fclose(stdin);
fclose(stdout);
#endif;
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -