博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 5305 Friends dfs
阅读量:7124 次
发布时间:2019-06-28

本文共 1427 字,大约阅读时间需要 4 分钟。

Friends

题目连接:

Description

There are n people and m pairs of friends. For every pair of friends, they can choose to become online friends (communicating using online applications) or offline friends (mostly using face-to-face communication). However, everyone in these n people wants to have the same number of online and offline friends (i.e. If one person has x onine friends, he or she must have x offline friends too, but different people can have different number of online or offline friends). Please determine how many ways there are to satisfy their requirements.

Input

The first line of the input is a single integer T (T=100), indicating the number of testcases.

For each testcase, the first line contains two integers n (1≤n≤8) and m (0≤m≤n(n−1)2), indicating the number of people and the number of pairs of friends, respectively. Each of the next m lines contains two numbers x and y, which mean x and y are friends. It is guaranteed that x≠y and every friend relationship will appear at most once.

Output

For each testcase, print one number indicating the answer.

Sample Input

2

3 3
1 2
2 3
3 1
4 4
1 2
2 3
3 4
4 1

Sample Output

0

2

Hint

题意

给你一个图,n点m边,你现在边分为两种,叫做“线上朋友”和“线下朋友”

现在对于每个人要求线上朋友和线下朋友一样多

问你有多少种方案。

题解:

数据范围太小了,直接暴力dfs就好了……

代码

#include
using namespace std;const int maxn = 115;int n,m,ans,l[maxn],r[maxn];vector
E[maxn];int cnt1[maxn],cnt2[maxn],cnt[maxn];void init(){ for(int i=0;i

转载地址:http://knael.baihongyu.com/

你可能感兴趣的文章
杨老师课堂之JavaWeb项目架构之NFS文件服务器
查看>>
Windows Linux 子系统可以在资源管理器中打开
查看>>
JavaWeb实训项目案例开发之在线图书网站开发【非常适合初学者】
查看>>
网页设计师和网页前端开发我该选择哪一个
查看>>
Apache Flink 漫谈系列(08) - SQL概览
查看>>
使用免费OA系统,让你成为职场锦鲤
查看>>
京东测试之道,这些你早该知道!
查看>>
jQuery可放大预览的图片滑块
查看>>
SpringBoot连接Redis哨兵模式
查看>>
【WPF】ComboBoxItem的禁用
查看>>
HTML5_CSS3仿Google Play垂直菜单
查看>>
达观杯文本智能处理挑战赛 练手代码实现
查看>>
Tornado 简单入门教程(一)——Demo1
查看>>
Pgpool-II 最新小版本更新发布,PgSQL 负载均衡中间件
查看>>
数据传输加密方式总结
查看>>
U-Boot启动过程完全分析
查看>>
深入理解Java中的底层阻塞原理及实现
查看>>
shell编程之转义和引用
查看>>
云盾.态势感知情报生态合作发布
查看>>
可视化生信分析利器-Galaxy(第一讲)
查看>>