1.current player 不一定是0
2.TLE想到记忆化搜索,想到怎样记录状态,注意到空位不大于10个,从这里做文章:
在搜索过程中,每个空位有三种情况:还是空的(0),被0填充(1),被1填充(2),用个三进制数记录(now)
在搜索过程中,需要枚举还没被填充的空位,需要记录对于每个状态哪个空位还没被填充的:被填充(0),被填充(1),用二进制数记录(state)
3.alpha+beta 剪枝,在搜索某个节点的子树过程中,发现当前子树怎样也无法得到比“当前已搜索过的子树得到的结果”(alpha或者beta)更优的结果时return
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include <set>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
using namespace std;
struct Point
{
int x,y;
Point()
{
Point(0,0);
}
Point(int _x,int _y)
{
x=_x;y=_y;
}
}p[100],ansp;
#define INF 10000
char mat[8][8];
int n,dp[60000],tot,pw3[60000],vis[8][8],best;
int dir[][2]={
{-1,0},{1,0},{0,-1},{0,1}};
int dfs(int r,int c,char side)
{
if(r<0 || r>=n || c<0 || c>=n || side!=mat[r][c] || vis[r][c])
return 0;
int cnt=1;
vis[r][c