标签:fine ++ reg using amp www. 棋盘 http pre
很显然,除非白子和黑子相邻,否则必然是黑子获胜虽然我并没有看出来
那么现在对黑子来说它要尽可能快的赢,对白子它要多苟一会儿
然后就是这个叫做对抗搜索的东西了
//minamoto
#include<bits/stdc++.h>
#define fp(i,a,b) for(register int i=a,I=b+1;i<I;++i)
#define fd(i,a,b) for(register int i=a,I=b-1;i>I;--i)
using namespace std;
inline int max(const int &x,const int &y){return x>y?x:y;}
inline int min(const int &x,const int &y){return x<y?x:y;}
inline int _abs(const int &x){return x<0?-x:x;}
int dx[]={1,0,-1,0,2,0,-2,0},dy[]={0,1,0,-1,0,2,0,-2};
const int N=21,inf=1e9;
int f[2][65][N][N][N][N];
int n,a,b,c,d;
int dfs(int x,int y,int a,int b,int c,int d){
if(y>3*n)return inf;if(a==c&&b==d)return x?inf:0;
if(f[x][y][a][b][c][d])return f[x][y][a][b][c][d];
int ans=0,xx,yy;
if(x){
ans=inf;fp(i,0,7){
xx=c+dx[i],yy=d+dy[i];
if(xx>=1&&xx<=n&&yy>=1&&yy<=n)ans=min(ans,dfs(0,y+1,a,b,xx,yy));
}
}else{
fp(i,0,3){
xx=a+dx[i],yy=b+dy[i];
if(xx>=1&&xx<=n&&yy>=1&&yy<=n)ans=max(ans,dfs(1,y+1,xx,yy,c,d));
}
}f[x][y][a][b][c][d]=++ans;return ans;
}
int main(){
// freopen("testdata.in","r",stdin);
scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
if(_abs(a-c)+_abs(d-b)==1)return puts("WHITE 1"),0;
return printf("BLACK %d\n",dfs(0,0,a,b,c,d)),0;
}
标签:fine ++ reg using amp www. 棋盘 http pre
原文地址:https://www.cnblogs.com/bztMinamoto/p/10040028.html