Bzoj 3294: [Cqoi2011] Play chess

Source: Internet
Author: User

3294: [Cqoi2011] Put pawn time limit:10 Sec Memory limit:128 MB
submit:628 solved:238
[Submit] [Status] [Discuss] Description Input

Enter the first behavior two integers n, m, C, number of rows, number of columns, and color of the pawn. The second line contains a C positive integer, which is the number of pieces per color. The total number of pieces in all colors is guaranteed to be no more than nm.

Output

The output is only one line, which is the remainder of the total scheme divided by 1,000,000,009.

Sample INPUT4 2 2
3 1
Sample Output8hint

n,m<=30 total pieces of c<=10 <=250

SOURCE Analysis:

Class is not good to listen to my tat ...

The most important thought of this problem is the idea of complementary set transformation.

F[i][j][k] represents the first K colors occupy the I Row J column scheme number, then how to transfer ...

F[i][j][k]=σf[i-x][j-y][k-1]*g[x][y][k]*c[i][x]*c[j][y]

What does G[x][y][k] stand for? The K-color just occupies the X-row y-column ... Feel this transfer is still very good to think of ...

But here's the question ... g[x][y][k] how to beg ...

We can convert the total number of programs minus the number of illegal schemes, i.e. g[i][j][k]=c[i*j][num[k]]-σg[x][y][k]*c[i][x]*c[j][y] ...

Pay attention to the border ... WA several times ... Qaq ...

Code:
1#include <algorithm>2#include <iostream>3#include <cstring>4#include <cstdio>5 //by Neighthorn6 #defineint long Long7 using namespacestd;8 9 Const intmaxn= -+5, mod=1e9+9;Ten  One intn,m,co,ans,num[maxn],c[maxn*maxn][maxn*MAXN],F[MAXN][MAXN][MAXN],G[MAXN][MAXN][MAXN]; A  -Signed Main (void){ -Memset (F,0,sizeof(f)); theMemset (G,0,sizeof(g));  -scanf"%lld%lld%lld",&n,&m,&co); -      for(intI=1; i<=co;i++) -scanf"%lld",&num[i]); +      for(intI=0; i<= the; i++) -c[i][0]=c[i][i]=1; +      for(intI=2; i<= the; i++) A          for(intj=1; j<i;j++) atC[i][j]= (c[i-1][j-1]+c[i-1][J])%MOD; -      for(intk=1; k<=co;k++) -          for(intI=1; i<=n;i++) -              for(intj=1; j<=m;j++) -                 if(I*j>=num[k]&&max (I,J) <=Num[k]) { -g[i][j][k]=c[i*J] [Num[k]]; in                      for(intx=1; x<=i;x++) -                          for(inty=1; y<=j;y++) to                             if((i-x) | | (J-y)) +g[i][j][k]= (g[i][j][k]-g[x][y][k]*c[i][x]%mod*c[j][y]%mod+mod)%MOD; -                 } thef[0][0][0]=1; *      for(intk=1; k<=co;k++) $          for(intI=1; i<=n;i++)Panax Notoginseng              for(intj=1; j<=m;j++) -                 if(i*j>=Num[k]) { the                      for(intx=1; x<=i;x++) +                          for(inty=1; y<=j;y++) A(f[i][j][k]+=f[i-x][j-y][k-1]*G[X][Y][K]%MOD*C[I][X]%MOD*C[J][Y]%MOD)%=MOD; the                 } +      for(intI=1; i<=n;i++) -          for(intj=1; j<=m;j++) $(Ans+=f[i][j][co]*c[n][i]%mod*c[m][j]%mod)%=MOD; $printf"%lld\n", ans); -     return 0; -}
View Code

by Neighthorn

Bzoj 3294: [Cqoi2011] Play chess

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.