title Link:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3687
Test Instructions: there are n days and n chapters, each day can complete a chapter, there is a m limit, indicating that the first day cannot complete chapter CI.
Ask how many plans you have to complete all of the chapters.
Ideas:
Learned a bit about the board polynomial knowledge http://wenku.baidu.com/link?url= Nxpyih0azzjti0tqd4qb91vq2rz0f3ycm7iqpu0pcbptlv75deivttj81sdtqdnv3lfbgalwjxxyx9zqcvsi0kauiagagpksebftumps5lc
The problem is the naked question of the forbidden position.
The formula for the cut-off arrangement:
1#include <bits/stdc++.h>2 using namespacestd;3 intN, M;4 #defineMAXN 555 #defineMoD 555666776 structNode7 {8 intD, C;9Node (intDdintCC) {D = DD; C =cc;}Ten }; OneVector <Node>node; A intMARK[MAXN][MAXN]; - intVISD[MAXN], VISC[MAXN]; - Long LongNUM[MAXN]; the Long Longans; - voidInit () - { -num[0] =1; num[1] =1; + for(inti =2; I <= -; i++) - { +Num[i] = num[i-1]*i%MoD; A } at } - voidDfsintPosintCNT) - { - if(Pos >M) - { - if(cnt%2) ans = ((ans-num[n-cnt])%mod + MoD)%MoD; in ElseAns = (ans + num[n-cnt])%MoD; - return; to } +DFS (pos+1, CNT); - if(!visd[node[pos]. D] &&!Visc[node[pos]. C]) the { *Visd[node[pos]. D] = Visc[node[pos]. C] =1; $DFS (pos+1, cnt+1);Panax NotoginsengVisd[node[pos]. D] = Visc[node[pos]. C] =0; - } the } + intMain () A { the //freopen ("In.txt", "R", stdin); + init (); - while(~SCANF ("%d%d", &n, &M)) $ { $ node.clear (); -memset (Mark,0,sizeof(Mark)); -Node.push_back (Node (-1, -1)); the for(inti =1; I <= M; i++) - {Wuyi intD, C; scanf"%d%d", &d, &c); the if(!Mark[d][c]) - { WuMARK[D][C] =1; - Node.push_back (node (d, c)); About } $ } -M = Node.size ()-1; -Ans =0; -memset (Visc,0,sizeof(Visc)); Amemset (VISD,0,sizeof(VISD)); +Dfs1,0); theprintf"%lld\n", ans); - } $ return 0; the}
Zoj 3687 the Review Plan I forbidden to arrange checkerboard polynomial