n个点m条边

m条边

求有几个环;

#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std; typedef long long LL;
typedef pair<int,int> PII; const int N=; LL ans;
int n,m,low;
LL dp[][N];
bool adj[N][N]; int main()
{
scanf("%d%d",&n,&m); for(int i=;i<m;i++)
{
int a,b; scanf("%d%d",&a,&b);
a--; b--;
adj[a][b]=adj[b][a]=;
} for(int i=;i<n;i++) dp[<<i][i]=; for(int i=;i<(<<n);i++)
{
int st=n+,cnt=;
for(int j=;j<n;j++) //这个状态中有多少个点
     if(i&(<<j))
{
st=min(st,j); cnt++;
} for(int j=;j<n;j++)
   if(dp[i][j])
{
if(adj[j][st]&&cnt>=) //点>=三 又要能回去
{
ans+=dp[i][j];
} for(int k=;k<n;k++)
        if(adj[j][k]&&k>st) //st是最小的点
{
if((i&(<<k))==) dp[i^(<<k)][k]+=dp[i][j];
}
}
} cout<<ans/<<endl; return ;
}

状态压缩codeforces 11 D的更多相关文章

  1. dp + 状态压缩 - Codeforces 580D Kefa and Dishes

    Kefa and Dishes Problem's Link Mean: 菜单上有n道菜,需要点m道.每道菜的美味值为ai. 有k个规则,每个规则:在吃完第xi道菜后接着吃yi可以多获得vi的美味值. ...

  2. Codeforces C. A Simple Task(状态压缩dp)

    题目描述:  A Simple Task time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  3. codeforces B - Preparing Olympiad(dfs或者状态压缩枚举)

    B. Preparing Olympiad You have n problems. You have estimated the difficulty of the i-th one as inte ...

  4. codeforces 713A A. Sonya and Queries(状态压缩)

    题目链接: A. Sonya and Queries time limit per test 1 second memory limit per test 256 megabytes input st ...

  5. codeforces 425B Sereja and Table(状态压缩,也可以数组模拟)

    题目 给出一个n*m的01矩阵, 让你最多改变k个里面的值(0变1,1变0), 使得0.1的连通分量是矩阵.输出最少步数 1 ≤ n, m ≤ 100; 1 ≤ k ≤ 10 题解: 如果01连通分量 ...

  6. Codeforces 4538 (状态压缩dp)Little Pony and Harmony Chest

    Little Pony and Harmony Chest 经典状态压缩dp #include <cstdio> #include <cstring> #include < ...

  7. Codeforces Round #235 (Div. 2) D. Roman and Numbers (数位dp、状态压缩)

    D. Roman and Numbers time limit per test 4 seconds memory limit per test 512 megabytes input standar ...

  8. [CodeForces 11D] A Simple Task - 状态压缩入门

    状态压缩/Bitmask 在动态规划问题中,我们会遇到需要记录一个节点是否被占用/是否到达过的情况.而对于一个节点数有多个甚至十几个的问题,开一个巨型的[0/1]数组显然不现实.于是就引入了状态压缩, ...

  9. SRM 513 2 1000CutTheNumbers(状态压缩)

    SRM 513 2 1000CutTheNumbers Problem Statement Manao has a board filled with digits represented as St ...

随机推荐

  1. Unity打包同一文件Hash不一样

    问题起因 游戏开发基本都会涉及到资源版本管理及更新,本文记录我在打包过程中遇到的一小问题: 开过中常用于标记资源版本的方法有计算文件Hash.VCS的版本等. 在Unity中对同一个资源文件进行多次打 ...

  2. Eclipse代码追踪功能说明

    在使用Java编写复杂一些的程序时,你会不会常常对一层层的继承关系和一次次方法的调用感到迷惘呢?幸亏我们有了Eclipse这么好的IDE可以帮我们理清头绪--这就要使用Eclipse强大的代码追踪功能 ...

  3. HTTP图解

    本节内容 俗话说好的开发,底层知识必须过硬,不然再创新的技术,你也理解不深入,比如python web开发工程师,想要学习任何一个框架,底层都是http和socket,底层抓牢了,学起来会很轻松,所以 ...

  4. Android:关于声明文件中android:process属性说明

    笔者在学习Android Service组件的过程中碰到了一个问题,就是在Android应用的声明文件Manifest.xml中有时候会对相关的服务标签设置一个android:process=&quo ...

  5. Html5 Egret游戏开发 成语大挑战(三)开始界面

    本篇需要在前面的素材准备完毕,才可以开始,使用egret的eui结合代码编辑,快速完成基本的界面搭建,这里写的可能比较细,目的是减少大家对于其中一些操作疑问,我去掉了很多无用的步骤,以最精简的流程来完 ...

  6. Html5 Egret游戏开发 成语大挑战(二)干净的eui项目和资源准备

    现在我们使用egret来起步开发一个名叫<成语大挑战>的小游戏,关于egret的开发环境就不在这里啰嗦了,直接去官方下载安装就可,egret是我见过开发环境部署最简单的解决方案,这个系列教 ...

  7. [java]java语言初探 servlet+jsp架构

    <<head first java>> https://www.tutorialspoint.com/jsp/jsp_architecture.htm JSP Processi ...

  8. 品读吴军"之"系列

    品读吴军"之"系列 这一两年,阅读吴军老师(微博,知乎专栏)的书占了我相当多的时间. 读吴军老师(微博,知乎专栏)的书,会让你心生敬佩,不禁想问"为什么有的作者有如此丰富 ...

  9. .Net Core+cenos7+Docker+Dockerfile 部署实践

    因为这段时间比较忙,同时也在抽时间将开发框架转移到 .net Core 上 所以写博客的时间就少了,这次我利用dockerfile成功将.net Core程序部署到了cenos7容器中,特抽时间把我的 ...

  10. byte[] 转字符串 中文乱码

    闲来无事,写了一个UWP的UDP/TCP小Demo,网上找了个网络调试助手,就兴冲冲的开始玩耍 结果“鸡同鸭讲”: 讲英文的时候大家都是abc,hello man!how are you? 讲中文的时 ...