//第一篇如此认真的搜索题,看了别人大概思路后,自己想的
//输入时先将门的钥匙存起来,对应的门的钥匙有几把,
//并将们的位置存起来,BFS时找到一把钥匙钥匙数量减一,
//找到门的时候如果钥匙够了则入队列,如果不够则将此位置
//标记为已访问过,如果其他遍历能够找齐钥匙并且门已经访问过
//说明们的位置可以到达,则将门入队列,最后找到G时结束
include
include
include
include
using namespace std;
int m, n;
char map[25][25];
int ans[6];
bool vis[22][22];
struct point{
int x, y;
};
int x1,y1,x2,y2,x3,y3,x4,y4,x5,y5;
queues;
int dir[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
void BFS(int xx, int yy){
int i, j;
while(!s.empty()) s.pop();
point p;
p.x = xx;
p.y = yy;
//vis[xx][yy] = true;
s.push(p);
while(!s.empty()){
p = s.front();
s.pop();
for(i = 0; i < 4; i++){
int x = p.x+dir[i][0];
int y = p.y+dir[i][1];
if(x>=0&&y>=0&&x