#include #include #include #include #include using namespace std; typedef complex pt; typedef vector snake; namespace std{ inline bool operator<(const pt &a,const pt &b){ return make_pair(real(a),imag(a)) &stone, int depth,queue > &dest) { static const pt vect[6+1]={ pt(0,-1),pt(1,-1),pt(1,0),pt(0,1),pt(-1,1),pt(-1,0),pt(0,0)}; #define adj(a,b) (find(vect,vect+6,a-b)-vect<6) int n=buf.size(); if (pos==n) dest.push(make_pair(depth,buf)); else for (int i=st;i<7;i++){ pt p=base[pos]+vect[i]; for (int j=0;j>n,n!=0;){ snake sn(n); for (int i=0;i>x>>y; sn[i]=pt(x,y); } int k;cin>>k; set st; for (int i=0;i>x>>y; st.insert(pt(x,y)); } int gx,gy;cin>>gx>>gy; pt g(gx,gy); queue > q; q.push(make_pair(0,sn)); set ss; for (;;){ int depth=q.front().first; snake cur=q.front().second; q.pop(); if (cur[0]==g||depth==20){ cout<