FriendsTime
limit:2000/1000 MS (java/others) Memory limit:65536/65536 K (java/others)
Total submission (s): 0 Accepted Submission (s): 0
Problem Descriptionthere isNPeople andmPairs of friends. For every pair of friends, they can choose to become online friends (communicating using online applications) or offline F Riends (mostly using face-to-face communication). However, everyone in thesen people wants to the Same number of online and offline friends (i.e. If one person has x onine Friends, he or she must have < Span id= "mathjax-span-14" class= "Mrow" >x offline Friends too, but different people can has different number of online or offline friends). Determine how many ways there is to satisfy their requirements.
Inputthe first line of the input was a single integerT (t=+) , indicating the number of testcases.
For each testcase, the first line contains the integersn (1≤n≤8) andm (0≤m≤< Span id= "mathjax-span-47" class= "Mi" >n ( n− 1) 2) , indicating the number of people and the number of pairs of friends, respectively. Each of the nextmLines contains, numbersxandy, which meanx and y is friends. It is guaranteed that x< Span id= "mathjax-span-73" class= "Mo" >≠y And every friend relationship would appear at the most once.
Outputfor each testcase, print one number indicating the answer. Sample Input23-1 Sample Output02
1#include <cstdio>2#include <cstring>3 4 5 intpu[100000000], pv[100000000];6 7 intwhite[Ten], black[Ten], deg[Ten];8 9 intp[ -];Ten intt, N, M; One A intMain () { - - for(inti =1; I <= -; i++) P[i] =1<<i; thescanf"%d", &t); - while(t--) { -memset (deg,0,sizeof(deg)); -scanf"%d%d", &n, &m); + for(inti =1; I <= m; i++) { -scanf"%d%d", &pu[i], &pv[i]); +deg[pu[i]]++; Adeg[pv[i]]++; at } - BOOLOK =true; - for(inti =1; I <= N; i++) { - if(deg[i]&1) { -OK =false; - Break; in } - } to if(!OK) { +Puts"0"); - Continue; the } * intMaxLen =1<<m; $ intAns =0;Panax Notoginseng for(inti =0; I <= maxlen; i++) { - for(intj =1; J <= M; J + +) { the if(I &P[j]) { +black[pu[j]]++; Ablack[pv[j]]++; the}Else { +white[pu[j]]++; -white[pv[j]]++; $ } $ } -OK =true; - for(inti =1; I <= N; i++) { the if(Black[i]! =White[i]) { -OK =false;Wuyi Break; the } - } Wu if(OK) ans++; -memset (Black,0,sizeof(black)); Aboutmemset (White,0,sizeof(white)); $ } -printf"%d\n", ans); - } - return 0; A}
View Code
More than 2015 schools