状态压缩codeforces 11 D
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的更多相关文章
- dp + 状态压缩 - Codeforces 580D Kefa and Dishes
Kefa and Dishes Problem's Link Mean: 菜单上有n道菜,需要点m道.每道菜的美味值为ai. 有k个规则,每个规则:在吃完第xi道菜后接着吃yi可以多获得vi的美味值. ...
- Codeforces C. A Simple Task(状态压缩dp)
题目描述: A Simple Task time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- codeforces B - Preparing Olympiad(dfs或者状态压缩枚举)
B. Preparing Olympiad You have n problems. You have estimated the difficulty of the i-th one as inte ...
- codeforces 713A A. Sonya and Queries(状态压缩)
题目链接: A. Sonya and Queries time limit per test 1 second memory limit per test 256 megabytes input st ...
- codeforces 425B Sereja and Table(状态压缩,也可以数组模拟)
题目 给出一个n*m的01矩阵, 让你最多改变k个里面的值(0变1,1变0), 使得0.1的连通分量是矩阵.输出最少步数 1 ≤ n, m ≤ 100; 1 ≤ k ≤ 10 题解: 如果01连通分量 ...
- Codeforces 4538 (状态压缩dp)Little Pony and Harmony Chest
Little Pony and Harmony Chest 经典状态压缩dp #include <cstdio> #include <cstring> #include < ...
- 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 ...
- [CodeForces 11D] A Simple Task - 状态压缩入门
状态压缩/Bitmask 在动态规划问题中,我们会遇到需要记录一个节点是否被占用/是否到达过的情况.而对于一个节点数有多个甚至十几个的问题,开一个巨型的[0/1]数组显然不现实.于是就引入了状态压缩, ...
- SRM 513 2 1000CutTheNumbers(状态压缩)
SRM 513 2 1000CutTheNumbers Problem Statement Manao has a board filled with digits represented as St ...
随机推荐
- VIJOS1240 朴素的网络游戏[DP]
描述 佳佳最近又迷上了某款类似于虚拟人生的网络游戏.在游戏中,佳佳是某旅行团的团长,他需要安排客户住进旅馆.旅馆给了佳佳的旅行团一个房间数的限制.每一个房间有不同的容纳人数和价钱(这个价格是房间的总价 ...
- 第16章 调色板管理器_16.4 一个DIB位图库的实现(2)
//接上一篇 //DibPal.h /*----------------------------------------------------------------- DIBPAL.H heade ...
- JAVA单例
单例模式: 1 public class Person{ 2 public static Person per//定义一个静态变量,用来储存当前类的对象 3 private Person()//构造方 ...
- SVN的使用方法
SVN的使用方法: 新建文件夹:文件夹1 在文件夹上点击右键--选择 SVN Checkout--弹出checkout窗口 下载文件的url获取:打开SVN--在要下载的文件上点击右键--点击Copy ...
- combobox 属性、事件、方法
一 .combobox 属性.事件.方法公共属性 名称 说明 AccessibilityObject 获取分配给该控件的 AccessibleObject. AccessibleDefaultActi ...
- Eclipse仿Visual AssistX 编辑着色插件
1. 风格下载 http://www.eclipsecolorthemes.org/?view=theme&id=4602 2. 风格的安装与卸载 http://www.cnblogs.com ...
- kali开启ssh
Kali 2.0安装之后需要做的事--使用SSH进行远程登录 2015年8月11日,Kali官方推出了新的kali系统2.0版本,此次升级最大的特点就是系统界面的设计理念更加先进,以及系统的升级方 ...
- SOAP-XML请求(iOS应用下集成携程api)
用携程机票为例: 携程联盟 飞机票.门票 联盟ID:278639 站点ID:739462 密钥KEY:BE57B925-E8CE-4AA2-AC8E-3EE4BBBB686F API_URL:open ...
- AIO 简介
from:http://blog.chinaunix.net/uid-11572501-id-2868654.html Linux的I/O机制经历了一下几个阶段的演进: 1. 同步阻塞I/O: 用 ...
- mysql新建用户的方法
新增 insert into mysql.user(Host,User,Password,ssl_cipher,x509_issuer,x509_subject) values("local ...