【搜索好题】bzoj1501 [NOI2005]智慧珠游戏

bzoj1501 [NOI2005]智慧珠游戏


搜索苟逼题系列。
暴力枚举每一种情况(包括旋转翻转全都考虑在内)然后码出代码。
(正解似乎不是这样子的)
那年好像还有平衡树苟逼题维护数列233333心疼2005noi
代码也就362行而已
PS.bzoj上的交题号是wfj_2333/滑稽
第五个点比较坑。。。我的方法是先搜出所有‘.'的联通块,有大小<3的就直接No Solution了,还有我瞎打乱了搜索顺序
(这个代码比我博客css还长、、、)

// It is made by XZZ
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
#define rep(a,b,c) for(rg int a=b;a<=c;a++)
#define drep(a,b,c) for(rg int a=b;a>=c;a--)
#define erep(a,b) for(rg int a=fir[b];a;a=nxt[a])
#define il inline
#define rg register
#define vd void
#define ok =='.'
#define st =ch
#define fr ='.'
#define can(a) (yes[a])
#define disable(a) yes[a]=0
#define able(a) yes[a]=1
#define nxt x,y+1
typedef long long ll;
il int gi(){
    rg int x=0;bool flg=0;rg char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')flg=1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return flg?-x:x;
}
const int n=10,m=12;
char s[233][233];
bool yes[233];
bool vis[20][20];
il int dfs(int x,int y){
    if(vis[x][y])return 0;
    vis[x][y]=1;
    if(s[x][y]!='.')return 0;
    return 1+dfs(x+1,y)+dfs(x-1,y)+dfs(x,y+1)+dfs(x,y-1);
}
il vd Init(){
    memset(s,'X',sizeof s);
    rep(i,1,n)scanf("%s",s[i]+1);
    rep(i,0,n+1)s[i][0]='X';
    rep(i,0,n+1)s[i][i+1]='X';
    rep(i,0,n+1)s[n+1][i]='X';
    rep(i,'A','L')yes[i]=1;
    rep(i,1,n)rep(j,1,i)if(!(s[i][j]ok))yes[s[i][j]]=0;
    rep(i,1,n)rep(j,1,i)if(s[i][j]ok&&!vis[i][j]&&dfs(i,j)<3){puts("No solution");exit(0);}
}
il vd Dfs(int x,int y){
    if(x==n+1){
        rep(i,1,n){
            rep(j,1,i)putchar(s[i][j]);
            puts("");
        }exit(0);
    }
    if(y==x+1){Dfs(x+1,1);return;}
    if(!(s[x][y]ok)){Dfs(nxt);return;}
    char ch;
    ch='B';
    if(can(ch)){
        disable(ch);s[x][y]st;
        if(s[x+1][y]ok&&s[x+2][y]ok&&s[x+3][y]ok){
            s[x+1][y]st,s[x+2][y]st,s[x+3][y]st,Dfs(nxt);
            s[x+1][y]fr,s[x+2][y]fr,s[x+3][y]fr;
        }
        if(s[x][y+1]ok&&s[x][y+2]ok&&s[x][y+3]ok){
            s[x][y+1]st,s[x][y+2]st,s[x][y+3]st,Dfs(nxt);
            s[x][y+1]fr,s[x][y+2]fr,s[x][y+3]fr;
        }
        s[x][y]fr;able(ch);
    }
    ch='C';
    if(can(ch)){
        disable(ch);s[x][y]st;
        if(s[x+1][y]ok&&s[x+2][y]ok&&s[x][y+1]ok){
            s[x+1][y]st,s[x+2][y]st,s[x][y+1]st,Dfs(nxt);
            s[x+1][y]fr,s[x+2][y]fr,s[x][y+1]fr;
        }
        if(s[x+1][y]ok&&s[x+2][y]ok&&s[x+2][y+1]ok){
            s[x+1][y]st,s[x+2][y]st,s[x+2][y+1]st,Dfs(nxt);
            s[x+1][y]fr,s[x+2][y]fr,s[x+2][y+1]fr;
        }
        if(s[x][y+1]ok&&s[x][y+2]ok&&s[x+1][y]ok){
            s[x][y+1]st,s[x][y+2]st,s[x+1][y]st,Dfs(nxt);
            s[x][y+1]fr,s[x][y+2]fr,s[x+1][y]fr;
        }
        if(s[x][y+1]ok&&s[x][y+2]ok&&s[x+1][y+2]ok){
            s[x][y+1]st,s[x][y+2]st,s[x+1][y+2]st,Dfs(nxt);
            s[x][y+1]fr,s[x][y+2]fr,s[x+1][y+2]fr;
        }
        if(s[x][y+1]ok&&s[x+1][y+1]ok&&s[x+2][y+1]ok){
            s[x][y+1]st,s[x+1][y+1]st,s[x+2][y+1]st,Dfs(nxt);
            s[x][y+1]fr,s[x+1][y+1]fr,s[x+2][y+1]fr;
        }
        if(s[x+1][y]ok&&s[x+2][y]ok&&s[x+2][y-1]ok){
            s[x+1][y]st,s[x+2][y]st,s[x+2][y-1]st,Dfs(nxt);
            s[x+1][y]fr,s[x+2][y]fr,s[x+2][y-1]fr;
        }
        if(y>2&&s[x+1][y]ok&&s[x+1][y-1]ok&&s[x+1][y-2]ok){
            s[x+1][y]st,s[x+1][y-1]st,s[x+1][y-2]st,Dfs(nxt);
            s[x+1][y]fr,s[x+1][y-1]fr,s[x+1][y-2]fr;
        }
        s[x][y]fr;able(ch);
    }
    ch='D';
    if(can(ch)){
        disable(ch);s[x][y]st;
        if(s[x+1][y]ok&&s[x+1][y+1]ok&&s[x][y+1]ok){
            s[x+1][y]st,s[x+1][y+1]st,s[x][y+1]st,Dfs(nxt);
            s[x+1][y]fr,s[x+1][y+1]fr,s[x][y+1]fr;
        }
        s[x][y]fr;able(ch);
    }
    ch='E';
    if(can(ch)){
        disable(ch);s[x][y]st;
        if(s[x+1][y]ok&&s[x+2][y]ok&&s[x][y+1]ok&&s[x][y+2]ok){
            s[x+1][y]st,s[x+2][y]st,s[x][y+1]st,s[x][y+2]st,Dfs(nxt);
            s[x+1][y]fr,s[x+2][y]fr,s[x][y+1]fr,s[x][y+2]fr;
        }
        if(s[x+1][y]ok&&s[x+2][y]ok&&s[x+2][y+1]ok&&s[x+2][y+2]ok){
            s[x+1][y]st,s[x+2][y]st,s[x+2][y+1]st,s[x+2][y+2]st,Dfs(nxt);
            s[x+1][y]fr,s[x+2][y]fr,s[x+2][y+1]fr,s[x+2][y+2]fr;
        }
        if(s[x+1][y+2]ok&&s[x+2][y+2]ok&&s[x][y+1]ok&&s[x][y+2]ok){
            s[x+1][y+2]st,s[x+2][y+2]st,s[x][y+1]st,s[x][y+2]st,Dfs(nxt);
            s[x+1][y+2]fr,s[x+2][y+2]fr,s[x][y+1]fr,s[x][y+2]fr;
        }
        if(s[x+1][y]ok&&s[x+2][y]ok&&s[x+2][y-1]ok&&s[x+2][y-2]ok){
            s[x+1][y]st,s[x+2][y]st,s[x+2][y-1]st,s[x+2][y-2]st,Dfs(nxt);
            s[x+1][y]fr,s[x+2][y]fr,s[x+2][y-1]fr,s[x+2][y-2]fr;
        }
        s[x][y]fr;able(ch);
    }
    ch='G';
    if(can(ch)){
        disable(ch);s[x][y]st;
        if(s[x+1][y]ok&&s[x][y+1]ok&&s[x][y+2]ok&&s[x+1][y+2]ok){
            s[x+1][y]st,s[x][y+1]st,s[x][y+2]st,s[x+1][y+2]st,Dfs(nxt);
            s[x+1][y]fr,s[x][y+1]fr,s[x][y+2]fr,s[x+1][y+2]fr;
        }
        if(s[x+1][y]ok&&s[x+1][y+1]ok&&s[x][y+2]ok&&s[x+1][y+2]ok){
            s[x+1][y]st,s[x+1][y+1]st,s[x][y+2]st,s[x+1][y+2]st,Dfs(nxt);
            s[x+1][y]fr,s[x+1][y+1]fr,s[x][y+2]fr,s[x+1][y+2]fr;
        }
        if(s[x][y+1]ok&&s[x+1][y+1]ok&&s[x+2][y+1]ok&&s[x+2][y]ok){
            s[x][y+1]st,s[x+1][y+1]st,s[x+2][y+1]st,s[x+2][y]st,Dfs(nxt);
            s[x][y+1]fr,s[x+1][y+1]fr,s[x+2][y+1]fr,s[x+2][y]fr;
        }
        if(s[x][y+1]ok&&s[x+1][y]ok&&s[x+2][y+1]ok&&s[x+2][y]ok){
            s[x][y+1]st,s[x+1][y]st,s[x+2][y+1]st,s[x+2][y]st,Dfs(nxt);
            s[x][y+1]fr,s[x+1][y]fr,s[x+2][y+1]fr,s[x+2][y]fr;
        }
        s[x][y]fr;able(ch);
    }
    ch='H';
    if(can(ch)){
        disable(ch);s[x][y]st;
        if(s[x+1][y]ok&&s[x+1][y+1]ok&&s[x][y+1]ok&&s[x][y+2]ok){
            s[x+1][y]st,s[x+1][y+1]st,s[x][y+1]st,s[x][y+2]st,Dfs(nxt);
            s[x+1][y]fr,s[x+1][y+1]fr,s[x][y+1]fr,s[x][y+2]fr;
        }
        if(s[x+1][y]ok&&s[x+1][y+1]ok&&s[x][y+1]ok&&s[x+1][y+2]ok){
            s[x+1][y]st,s[x+1][y+1]st,s[x][y+1]st,s[x+1][y+2]st,Dfs(nxt);
            s[x+1][y]fr,s[x+1][y+1]fr,s[x][y+1]fr,s[x+1][y+2]fr;
        }
        if(s[x+1][y]ok&&s[x+1][y+1]ok&&s[x][y+1]ok&&s[x+2][y]ok){
            s[x+1][y]st,s[x+1][y+1]st,s[x][y+1]st,s[x+2][y]st,Dfs(nxt);
            s[x+1][y]fr,s[x+1][y+1]fr,s[x][y+1]fr,s[x+2][y]fr;
        }
        if(s[x+1][y]ok&&s[x+1][y+1]ok&&s[x][y+1]ok&&s[x+2][y+1]ok){
            s[x+1][y]st,s[x+1][y+1]st,s[x][y+1]st,s[x+2][y+1]st,Dfs(nxt);
            s[x+1][y]fr,s[x+1][y+1]fr,s[x][y+1]fr,s[x+2][y+1]fr;
        }
        if(s[x+1][y]ok&&s[x+1][y+1]ok&&s[x][y+1]ok&&s[x+1][y-1]ok){
            s[x+1][y]st,s[x+1][y+1]st,s[x][y+1]st,s[x+1][y-1]st,Dfs(nxt);
            s[x+1][y]fr,s[x+1][y+1]fr,s[x][y+1]fr,s[x+1][y-1]fr;
        }
        if(s[x+1][y]ok&&s[x+2][y]ok&&s[x+1][y+1]ok&&s[x+2][y+1]ok){
            s[x+1][y]st,s[x+2][y]st,s[x+1][y+1]st,s[x+2][y+1]st,Dfs(nxt);
            s[x+1][y]fr,s[x+2][y]fr,s[x+1][y+1]fr,s[x+2][y+1]fr;
        }
        if(s[x+1][y]ok&&s[x+2][y]ok&&s[x+1][y-1]ok&&s[x+2][y-1]ok){
            s[x+1][y]st,s[x+2][y]st,s[x+1][y-1]st,s[x+2][y-1]st,Dfs(nxt);
            s[x+1][y]fr,s[x+2][y]fr,s[x+1][y-1]fr,s[x+2][y-1]fr;
        }
        if(s[x][y+1]ok&&s[x+1][y+1]ok&&s[x][y+2]ok&&s[x+1][y+2]ok){
            s[x][y+1]st,s[x+1][y+1]st,s[x][y+2]st,s[x+1][y+2]st,Dfs(nxt);
            s[x][y+1]fr,s[x+1][y+1]fr,s[x][y+2]fr,s[x+1][y+2]fr;
        }
        s[x][y]fr;able(ch);
    }
    ch='A';
    if(can(ch)){
        disable(ch);s[x][y]st;
        if(s[x+1][y]ok&&s[x][y+1]ok){
            s[x+1][y]st,s[x][y+1]st,Dfs(nxt);
            s[x+1][y]fr,s[x][y+1]fr;
        }
        if(s[x+1][y+1]ok&&s[x][y+1]ok){
            s[x+1][y+1]st,s[x][y+1]st,Dfs(nxt);
            s[x+1][y+1]fr,s[x][y+1]fr;
        }
        if(s[x+1][y]ok&&s[x+1][y+1]ok){
            s[x+1][y]st,s[x+1][y+1]st,Dfs(nxt);
            s[x+1][y]fr,s[x+1][y+1]fr;
        }
        if(s[x+1][y]ok&&s[x+1][y-1]ok){
            s[x+1][y]st,s[x+1][y-1]st,Dfs(nxt);
            s[x+1][y]fr,s[x+1][y-1]fr;
        }
        s[x][y]fr;able(ch);
    }
    ch='L';
    if(can(ch)){
        disable(ch);s[x][y]st;
        if(s[x][y+1]ok&&s[x+1][y+1]ok&&s[x+2][y+1]ok&&s[x+3][y+1]ok){
            s[x][y+1]st,s[x+1][y+1]st,s[x+2][y+1]st,s[x+3][y+1]st,Dfs(nxt);
            s[x][y+1]fr,s[x+1][y+1]fr,s[x+2][y+1]fr,s[x+3][y+1]fr;
        }
        if(s[x][y+1]ok&&s[x][y+2]ok&&s[x][y+3]ok&&s[x+1][y+3]ok){
            s[x][y+1]st,s[x][y+2]st,s[x][y+3]st,s[x+1][y+3]st,Dfs(nxt);
            s[x][y+1]fr,s[x][y+2]fr,s[x][y+3]fr,s[x+1][y+3]fr;
        }
        if(s[x+1][y]ok&&s[x+2][y]ok&&s[x+3][y]ok&&s[x+3][y-1]ok){
            s[x+1][y]st,s[x+2][y]st,s[x+3][y]st,s[x+3][y-1]st,Dfs(nxt);
            s[x+1][y]fr,s[x+2][y]fr,s[x+3][y]fr,s[x+3][y-1]fr;
        }
        if(s[x+1][y]ok&&s[x+2][y]ok&&s[x+3][y]ok&&s[x+3][y+1]ok){
            s[x+1][y]st,s[x+2][y]st,s[x+3][y]st,s[x+3][y+1]st,Dfs(nxt);
            s[x+1][y]fr,s[x+2][y]fr,s[x+3][y]fr,s[x+3][y+1]fr;
        }
        if(s[x+1][y]ok&&s[x+1][y+1]ok&&s[x+1][y+2]ok&&s[x+1][y+3]ok){
            s[x+1][y]st,s[x+1][y+1]st,s[x+1][y+2]st,s[x+1][y+3]st,Dfs(nxt);
            s[x+1][y]fr,s[x+1][y+1]fr,s[x+1][y+2]fr,s[x+1][y+3]fr;
        }
        if(s[x+1][y]ok&&s[x+1][y-1]ok&&s[x+1][y-2]ok&&s[x+1][y-3]ok){
            s[x+1][y]st,s[x+1][y-1]st,s[x+1][y-2]st,s[x+1][y-3]st,Dfs(nxt);
            s[x+1][y]fr,s[x+1][y-1]fr,s[x+1][y-2]fr,s[x+1][y-3]fr;
        }
        if(s[x+1][y]ok&&s[x+2][y]ok&&s[x+3][y]ok&&s[x][y+1]ok){
            s[x+1][y]st,s[x+2][y]st,s[x+3][y]st,s[x][y+1]st,Dfs(nxt);
            s[x+1][y]fr,s[x+2][y]fr,s[x+3][y]fr,s[x][y+1]fr;
        }
        if(s[x+1][y]ok&&s[x][y+1]ok&&s[x][y+2]ok&&s[x][y+3]ok){
            s[x+1][y]st,s[x][y+1]st,s[x][y+2]st,s[x][y+3]st,Dfs(nxt);
            s[x+1][y]fr,s[x][y+1]fr,s[x][y+2]fr,s[x][y+3]fr;
        }
        s[x][y]fr;able(ch);
    }
    ch='I';
    if(can(ch)){
        disable(ch);s[x][y]st;
        if(s[x][y+1]ok&&s[x][y+2]ok&&s[x+1][y+2]ok&&s[x+1][y+3]ok){
            s[x][y+1]st,s[x][y+2]st,s[x+1][y+2]st,s[x+1][y+3]st,Dfs(nxt);
            s[x][y+1]fr,s[x][y+2]fr,s[x+1][y+2]fr,s[x+1][y+3]fr;
        }
        if(s[x][y+1]ok&&s[x+1][y+1]ok&&s[x+1][y+2]ok&&s[x+1][y+3]ok){
            s[x][y+1]st,s[x+1][y+1]st,s[x+1][y+2]st,s[x+1][y+3]st,Dfs(nxt);
            s[x][y+1]fr,s[x+1][y+1]fr,s[x+1][y+2]fr,s[x+1][y+3]fr;
        }
        if(s[x+1][y]ok&&s[x+1][y-1]ok&&s[x+2][y-1]ok&&s[x+3][y-1]ok){
            s[x+1][y]st,s[x+1][y-1]st,s[x+2][y-1]st,s[x+3][y-1]st,Dfs(nxt);
            s[x+1][y]fr,s[x+1][y-1]fr,s[x+2][y-1]fr,s[x+3][y-1]fr;
        }
        if(s[x+1][y]ok&&s[x+2][y]ok&&s[x+2][y-1]ok&&s[x+3][y-1]ok){
            s[x+1][y]st,s[x+2][y]st,s[x+2][y-1]st,s[x+3][y-1]st,Dfs(nxt);
            s[x+1][y]fr,s[x+2][y]fr,s[x+2][y-1]fr,s[x+3][y-1]fr;
        }
        if(s[x+1][y]ok&&s[x+1][y+1]ok&&s[x+2][y+1]ok&&s[x+3][y+1]ok){
            s[x+1][y]st,s[x+1][y+1]st,s[x+2][y+1]st,s[x+3][y+1]st,Dfs(nxt);
            s[x+1][y]fr,s[x+1][y+1]fr,s[x+2][y+1]fr,s[x+3][y+1]fr;
        }
        if(s[x+1][y]ok&&s[x+2][y]ok&&s[x+2][y+1]ok&&s[x+3][y+1]ok){
            s[x+1][y]st,s[x+2][y]st,s[x+2][y+1]st,s[x+3][y+1]st,Dfs(nxt);
            s[x+1][y]fr,s[x+2][y]fr,s[x+2][y+1]fr,s[x+3][y+1]fr;
        }
        if(y>1&&s[x][y+1]ok&&s[x+1][y]ok&&s[x+1][y-1]ok&&s[x+1][y-2]ok){
            s[x][y+1]st,s[x+1][y]st,s[x+1][y-1]st,s[x+1][y-2]st,Dfs(nxt);
            s[x][y+1]fr,s[x+1][y]fr,s[x+1][y-1]fr,s[x+1][y-2]fr;
        }
        if(y>1&&s[x][y+1]ok&&s[x][y+2]ok&&s[x+1][y]ok&&s[x+1][y-1]ok){
            s[x][y+1]st,s[x][y+2]st,s[x+1][y]st,s[x+1][y-1]st,Dfs(nxt);
            s[x][y+1]fr,s[x][y+2]fr,s[x+1][y]fr,s[x+1][y-1]fr;
        }
        s[x][y]fr;able(ch);
    }
    ch='J';
    if(can(ch)){
        disable(ch);s[x][y]st;
        if(s[x+1][y]ok&&s[x+1][y+1]ok&&s[x+2][y]ok&&s[x+1][y-1]ok){
            s[x+1][y]st,s[x+1][y+1]st,s[x+2][y]st,s[x+1][y-1]st,Dfs(nxt);
            s[x+1][y]fr,s[x+1][y+1]fr,s[x+2][y]fr,s[x+1][y-1]fr;
        }
        s[x][y]fr;able(ch);
    }
    ch='F';
    if(can(ch)){
        disable(ch);s[x][y]st;
        if(s[x+1][y]ok&&s[x+1][y-1]ok&&s[x+1][y+1]ok&&s[x+1][y+2]ok){
            s[x+1][y]st,s[x+1][y-1]st,s[x+1][y+1]st,s[x+1][y+2]st,Dfs(nxt);
            s[x+1][y]fr,s[x+1][y-1]fr,s[x+1][y+1]fr,s[x+1][y+2]fr;
        }
        if(y>1&&s[x+1][y]ok&&s[x+1][y-1]ok&&s[x+1][y+1]ok&&s[x+1][y-2]ok){
            s[x+1][y]st,s[x+1][y-1]st,s[x+1][y+1]st,s[x+1][y-2]st,Dfs(nxt);
            s[x+1][y]fr,s[x+1][y-1]fr,s[x+1][y+1]fr,s[x+1][y-2]fr;
        }
        if(s[x+1][y]ok&&s[x+1][y+1]ok&&s[x+2][y]ok&&s[x+3][y]ok){
            s[x+1][y]st,s[x+1][y+1]st,s[x+2][y]st,s[x+3][y]st,Dfs(nxt);
            s[x+1][y]fr,s[x+1][y+1]fr,s[x+2][y]fr,s[x+3][y]fr;
        }
        if(s[x+1][y]ok&&s[x+1][y-1]ok&&s[x+2][y]ok&&s[x+3][y]ok){
            s[x+1][y]st,s[x+1][y-1]st,s[x+2][y]st,s[x+3][y]st,Dfs(nxt);
            s[x+1][y]fr,s[x+1][y-1]fr,s[x+2][y]fr,s[x+3][y]fr;
        }
        if(s[x][y+1]ok&&s[x+1][y+1]ok&&s[x][y+2]ok&&s[x][y+3]ok){
            s[x][y+1]st,s[x+1][y+1]st,s[x][y+2]st,s[x][y+3]st,Dfs(nxt);
            s[x][y+1]fr,s[x+1][y+1]fr,s[x][y+2]fr,s[x][y+3]fr;
        }
        if(s[x][y+1]ok&&s[x+1][y+2]ok&&s[x][y+2]ok&&s[x][y+3]ok){
            s[x][y+1]st,s[x+1][y+2]st,s[x][y+2]st,s[x][y+3]st,Dfs(nxt);
            s[x][y+1]fr,s[x+1][y+2]fr,s[x][y+2]fr,s[x][y+3]fr;
        }
        if(s[x+1][y]ok&&s[x+2][y+1]ok&&s[x+2][y]ok&&s[x+3][y]ok){
            s[x+1][y]st,s[x+2][y+1]st,s[x+2][y]st,s[x+3][y]st,Dfs(nxt);
            s[x+1][y]fr,s[x+2][y+1]fr,s[x+2][y]fr,s[x+3][y]fr;
        }
        if(s[x+1][y]ok&&s[x+2][y-1]ok&&s[x+2][y]ok&&s[x+3][y]ok){
            s[x+1][y]st,s[x+2][y-1]st,s[x+2][y]st,s[x+3][y]st,Dfs(nxt);
            s[x+1][y]fr,s[x+2][y-1]fr,s[x+2][y]fr,s[x+3][y]fr;
        }
        s[x][y]fr;able(ch);
    }
    ch='K';
    if(can(ch)){
        disable(ch);s[x][y]st;
        if(s[x+1][y]ok&&s[x+1][y+1]ok&&s[x+2][y+1]ok&&s[x+2][y+2]ok){
            s[x+1][y]st,s[x+1][y+1]st,s[x+2][y+1]st,s[x+2][y+2]st,Dfs(nxt);
            s[x+1][y]fr,s[x+1][y+1]fr,s[x+2][y+1]fr,s[x+2][y+2]fr;
        }
        if(s[x][y+1]ok&&s[x+1][y+1]ok&&s[x+1][y+2]ok&&s[x+2][y+2]ok){
            s[x][y+1]st,s[x+1][y+1]st,s[x+1][y+2]st,s[x+2][y+2]st,Dfs(nxt);
            s[x][y+1]fr,s[x+1][y+1]fr,s[x+1][y+2]fr,s[x+2][y+2]fr;
        }
        if(y>1&&s[x+1][y]ok&&s[x+1][y-1]ok&&s[x+2][y-1]ok&&s[x+2][y-2]ok){
            s[x+1][y]st,s[x+1][y-1]st,s[x+2][y-1]st,s[x+2][y-2]st,Dfs(nxt);
            s[x+1][y]fr,s[x+1][y-1]fr,s[x+2][y-1]fr,s[x+2][y-2]fr;
        }
        if(s[x][y+1]ok&&s[x+1][y]ok&&s[x+1][y-1]ok&&s[x+2][y-1]ok){
            s[x][y+1]st,s[x+1][y]st,s[x+1][y-1]st,s[x+2][y-1]st,Dfs(nxt);
            s[x][y+1]fr,s[x+1][y]fr,s[x+1][y-1]fr,s[x+2][y-1]fr;
        }
        s[x][y]fr;able(ch);
    }
}
int main(){
    Init();
    Dfs(1,1);
    puts("No solution");
    return 0;
}
posted @ 2017-10-04 14:30  菜狗xzz  阅读(1179)  评论(1编辑  收藏  举报