#include #include #include using namespace std; const int N = 10; struct Domino { int x,y; }d[40]; struct Uncover { int x,y; }u[N*N]; int map[N][N],st[3][9],t,num; int dir[2][2]={{0,1},{1,0}}; bool vis[N][N],flag; void init() { for(int i=1;i<=8;i++) for(int j=i+1;j<=9;j++) { d[t].x=i,d[t].y=j; t++; } } bool isfinish() { for(int i=0;i<3;i++) for(int j=0;j<9;j++) if(st[i][j]!=((1<<9)-1)) return false; return true; } bool check(int x,int y,int xx,int yy,int first,int second) { int ss1=(x/3)*3+y/3,ss2=(xx/3)*3+yy/3; first--,second--; if((st[0][x]&(1<=9 || yy<0 || yy>=9 || map[xx][yy]!=0) continue; if(!check(x,y,xx,yy,first,second)) continue; map[x][y]=first,map[xx][yy]=second; if(map[u[temp+1].x][u[temp+1].y]==0) dfs(temp+1); else { while(temp