Zoj 3687 the Review Plan I forbidden to arrange checkerboard polynomial

Source: Internet
Author: User

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

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.