ZOJ 3687 the Review Plan I

Source: Internet
Author: User

The Review Plan itime limit:5000msmemory limit:65536kbthis problem would be judged onZju. Original id:3687
64-bit integer IO format: %lld Java class name: Main

Michael takes the discrete Mathematics course in this semester. Now it's close to the final exam, and he wants to take a complete review of this course.

The whole book he needs to review have N chapter, because of the knowledge system of the course is kinds of discrete as Its name, and due to his perfectionism, he wants to arrange exactly days to take his N review, and one chapter by EAC H Day.

But at the same time, he had other courses to review and he also have to take time-to-hang out with his girlfriend or does so Me other things. So the-the free time he had in each of the different, he can not be finish a big chapter in some particular busy days.

To make his perfect review plan, the He needs you to the help him.

Input

There is multiple test cases. For each test case:

The first line contains-integers N (1≤ N ≤50), M (0≤ M ≤25), is the number of the and N also the Nu Mber of the chapters in the book.

Then followed by M lines. Each line contains-integers D (1≤ D ≤ N ) C and (1≤ C ≤ N ), means at the D th day he can not finish The review of the C th chapter.

There is a blank line between every and cases.

Process to the end of input.

Output

One line for each case. The number of the different appropriate plans module 55566677.

Sample Input
4 31 24 32 16 51 12 63 54 43 4
Sample Output
11284
SourceZOJ Monthly, March 2013AuthorLI, Huang problem Solving: the principle of tolerance + search
1#include <bits/stdc++.h>2 using namespacestd;3typedefLong LongLL;4 Const intMAXN =Wuyi;5 ConstLL mod =55566677;6LL F[MAXN] = {1};7 voidinit () {8      for(inti =1; i < MAXN; ++i)9F[i] = f[i-1]*i%MoD;Ten } OneLL ret =0; A BOOLvis[maxn][2]; - intd[maxn],c[maxn],n,m; - voidDfsintCurintCNT) { the     if(cur >=m) { -         if(cnt&1) ret = (ret-f[n-cnt] + MoD)%MoD; -         ElseRET = (ret + f[n-cnt])%MoD; -         return; +     } -DFS (cur+1, CNT); +     if(!vis[d[cur]][0] &&!vis[c[cur]][1]){ Avis[d[cur]][0] = vis[c[cur]][1] =true; atDFS (cur +1, CNT +1); -vis[d[cur]][0] = vis[c[cur]][1] =false; -     } - } - BOOLCC[MAXN][MAXN]; - intMain () { in init (); -      while(~SCANF ("%d%d",&n,&m)) { toRET =0; +memset (Vis,false,sizeofvis); -Memset (CC,false,sizeofcc); the          for(inti =0; I < m; ++i) { *scanf"%d%d", d+i,c+i); $             if(Cc[d[i]][c[i]]) {Panax Notoginseng--i; ---m; the}ElseCc[d[i]][c[i]] =true; +         } ADfs0,0); theprintf"%lld\n", ret); +     } -     return 0; $}
View Code

ZOJ 3687 the Review Plan I

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.