预处理出哪两个点之间是可以划的,枚举一个端点,把所有点按时针排序,排序可以用叉积算,然后扫一遍即可
然后区间dp即可,f[i][j]=sigma f[i][k]*f[k][j](ik和kj都可以划)
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<queue>
#include<stack>
using namespace std;
#define MAXN 610
#define MAXM 20010
#define INF 1000000000
#define MOD 1000000007
#define eps 1e-8
#define ll long long
char xB[1<<15],*xS=xB,*xT=xB;
#define getc() (xS==xT&&(xT=(xS=xB)+fread(xB,1,1<<15,stdin),xS==xT)?0:*xS++)
inline int read()
{
int x=0,f=1;char ch=getc();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getc();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getc();}
return x*f;
}
struct pt{
int x;
int y;
pt(){
}
pt(int _x,int _y){
x=_x;
y=_y;
}
friend pt operator -(pt x,pt y){
return pt(x.x-y.x,x.y-y.y);
}
friend int operator *(pt x,pt y){
return x.x*y.y-x.y*y.x;
}
};
int mod;
int n,m;
pt a[MAXN],b[MAXM];
bool abl[MAXN][MAXN];
int f[MAXN][MAXN];
bool vis[MAXN][MAXN];
pt now;
bool operator <(pt x,pt y){
return (x-now)*(y-now)<0;
}
int main(){
int i,j,k;
scanf("%d%d%d",&n,&m,&mod);
for(i=1;i<=n;i++){
a[i].x=read();
a[i].y=read();
}
for(i=1;i<=m;i++){
b[i].x=read();
b[i].y=read();
}
for(i=1;i<=n;i++){
now=a[i];
sort(b+1,b+m+1);
int t=0;
int wzh=1;
for(j=i+1;j<=n;j++){
while(wzh<=m&&(b[wzh]-now)*(a[j]-now)<=0){
t++;
wzh++;
}
if(!((t&1)||(t&&(b[wzh-1]-now)*(a[j]-now)==0))){
abl[j][i]=abl[i][j]=1;
}
}
}
//*
for(i=1;i<n;i++){
f[i][i+1]=1;
}
for(k=1;k<n;k++){
for(i=1;i+k<=n;i++){
for(j=i+1;j<i+k;j++){
if(abl[i][j]&&abl[j][i+k]){
(f[i][i+k]+=f[i][j]*f[j][i+k])%=mod;
}
}
}
}
//*/
printf("%d\n",f[1][n]);
return 0;
}
/*
6 4 1007
-5 18
-3 7192
2 8046
5 -17
3 -7191
-2 -8045
-3 11
3 -10
3 -5476
1 -6279
6 0 100
-1 1
1 1
2 0
1 -1
-1 -1
-2 0
*/