You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
1.7 KiB
101 lines
1.7 KiB
#include <iostream>
|
|
using namespace std;
|
|
|
|
char map[50][50];
|
|
int visit[50][50];
|
|
int next_[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
|
|
int n,m,tx,ty,startx,starty,sum,max_=0;
|
|
int head,tail,mx,my;
|
|
|
|
int getboom(int x,int y)
|
|
{
|
|
int sum_=0,i,j;
|
|
i=x,j=y;
|
|
while(map[i][j]!='#')
|
|
{
|
|
if(map[i][j]=='G')
|
|
sum_++;
|
|
i--;
|
|
}
|
|
i=x;j=y;
|
|
while(map[i][j]!='#')
|
|
{
|
|
if(map[i][j]=='G')
|
|
sum_++;
|
|
i++;
|
|
}
|
|
i=x;j=y;
|
|
while(map[i][j]!='#')
|
|
{
|
|
if(map[i][j]=='G')
|
|
sum_++;
|
|
j--;
|
|
}
|
|
i=x;j=y;
|
|
while(map[i][j]!='#')
|
|
{
|
|
if(map[i][j]=='G')
|
|
sum_++;
|
|
j++;
|
|
}
|
|
return sum_;
|
|
}
|
|
|
|
void dfs(int x,int y)
|
|
{
|
|
int i;
|
|
for(i=0;i<4;i++)
|
|
{
|
|
tx=x+next_[i][0];
|
|
ty=y+next_[i][1];
|
|
if(tx<1 || tx>n || ty<1 || ty>m)
|
|
continue;
|
|
if(map[tx][ty]=='.' && visit[tx][ty]==0)
|
|
{
|
|
visit[tx][ty]=1;
|
|
sum=getboom(tx,ty);
|
|
if(sum>max_)
|
|
{
|
|
max_=sum;
|
|
mx=tx;
|
|
my=ty;
|
|
}
|
|
dfs(tx,ty);
|
|
//visit[tx][ty]=0;
|
|
}
|
|
}
|
|
}
|
|
int main()
|
|
{
|
|
int i,j;
|
|
n=13,m=13;
|
|
startx=3,starty=3;
|
|
for(i=1;i<=n;i++)
|
|
{
|
|
for(j=1;j<=m;j++)
|
|
{
|
|
cin>>map[i][j];
|
|
}
|
|
}
|
|
visit[startx][starty]=1;
|
|
max_=getboom(startx,starty);
|
|
mx=startx;
|
|
my=starty;
|
|
dfs(startx,starty);
|
|
cout<<max_<<' '<<mx<<' '<<my;
|
|
}
|
|
//#############
|
|
//#GG.GGG#GGG.#
|
|
//###.#G#G#G#G#
|
|
//#.......#..G#
|
|
//#G#.###.#G#G#
|
|
//#GG.GGG.#.GG#
|
|
//#G#.#G#.#.#.#
|
|
//##G...G.....#
|
|
//#G#.#G###.#G#
|
|
//#...G#GGG.GG#
|
|
//#G#.#G#G#.#G#
|
|
//#GG.GGG#G.GG#
|
|
//#############
|
|
|