#include #include #include #include using namespace std; struct node { int x,y,x1,y1,x2,y2,x3,y3; int step; }; bool vist[8][8][8][8][8][8][8][8]; int n,m,t[4][2]= {1,0,-1,0,0,1,0,-1}; int f[10][10],cnt; char s[10][10]; queueq; void bfs() { while(!q.empty()) { node p=q.front(); q.pop(); if(f[p.x1][p.y1]&&f[p.x2][p.y2]&&f[p.x3][p.y3]) { printf("%d\n",p.step); return; } for(int i=0; i<4; i++) { int mx=p.x+t[i][0]; int my=p.y+t[i][1]; int xx=p.x+2*t[i][0]; int yy=p.y+2*t[i][1]; if(mx>=0&&mx=0&&my=0&&xx=0&&yy0) { memset(vist,false,sizeof(vist)); memset(f,0,sizeof(f)); while(!q.empty()) q.pop(); cnt=0; int w=0; node p; for(int i=0; i