思路:
Claris大大说了
排序以后 这个可以看成是括号序列
f[i][j][k]表示到了i j个左括号 k个右括号
(f[i][j][k]+=f[i-1][j][k])%=p;
if(node[i].id)(f[i][j][k+1]+=f[i-1][j][k])%=p;
else (f[i][j+1][k]+=f[i-1][j][k])%=p;
//By SiriusRen #include <cstdio> #include <algorithm> using namespace std; int n,m,K,a[1111],b[1111],f[2222][12][12],top,p=1000000009; struct Node{int wei,id;Node(){}Node(int x,int y){wei=x,id=y;}}node[2222]; bool cmp(Node x,Node y){if(x.wei!=y.wei)return x.wei<y.wei;return x.id>y.id;} int main(){ scanf("%d%d%d",&n,&m,&K); for(int i=1;i<=n;i++)scanf("%d",&a[i]),node[++top]=Node(a[i],1);//FJ for(int i=1;i<=m;i++)scanf("%d",&b[i]),node[++top]=Node(b[i],0);//FP sort(node+1,node+1+top,cmp); f[0][0][0]=1; for(int i=1;i<=top;i++) for(int j=0;j<=K;j++) for(int k=0;k<=K;k++) if(j>=k){ (f[i][j][k]+=f[i-1][j][k])%=p; if(node[i].id)(f[i][j][k+1]+=f[i-1][j][k])%=p; else (f[i][j+1][k]+=f[i-1][j][k])%=p; } printf("%d ",f[top][K][K]); }