hdu 4025 2011上海赛区网络赛E 压缩 ***
直接T了,居然可以这么剪枝
题解链接:点我
#include<cstdio>
#include<map>
#include<cstring>
#define ll __int64
using namespace std;
ll a[],x[][],ans;
map<ll,ll>p;
void dfs(int d,int n,ll res,int f)
{
if(d==n){
if(f) p[res]++
if(res==) ans++;
return ;
}
for(int i=;i<=x[d][];i++)
{
ll temp=x[d][i]&a[d];
dfs(d+,n,temp^res);
}
}
int main()
{
int t,i,j,n,m,k;
ll temp=,te;
#ifndef ONLINE_JUDGE
freopen("1.in","r",stdin);
#endif
scanf("%d",&t);
while(t--){
scanf("%d%d",&n,&m);
memset(a,,sizeof(a));
memset(x,,sizeof(x));
p.clear();
for(i=;i<n;i++)
for(j=;j<m;j++){
scanf("%I64d",&te);
if(te)
a[j]|=(temp<<(*i));
}
for(i=;i<m;i++){
scanf("%d",&x[i][]);
for(j=;j<=x[i][];j++){
scanf("%I64d",&te);
x[i][j]=te;
for(k=;k<n;k++){
x[i][j]|=(te<<(*k));
}
}
}
dfs(,m/,,);
dfs(m/,m,,);
printf("%I64d\n",ans);
}
return ;
}
hdu 4025 2011上海赛区网络赛E 压缩 ***的更多相关文章
- hdu 4026 2011上海赛区网络赛F TSP ****
没看过TSP,先mark //4838039 2011-10-27 23:04:15 Accepted 4026 2343MS 31044K 3143 B C++ Geners //状态压缩DP的TS ...
- hdu 4023 2011上海赛区网络赛C 贪心+模拟
以为是贪心,结果不是,2333 贪心最后对自己绝对有利的情况 点我 #include<cstdio> #include<iostream> #include<algori ...
- hdu 4028 2011上海赛区网络赛H dp+map离散
一开始用搜索直接超时,看题解会的 #include<iostream> #include<cstdio> #include<map> #include<cst ...
- hdu 4027 2011上海赛区网络赛G 线段树 成段平方根 ***
不能直接使用成段增减的那种,因为一段和的平方根不等于平方根的和,直接记录是否为1,是1就不需要更新了 #include<cstdio> #include<iostream> # ...
- hdu 4035 2011成都赛区网络赛E 概率dp ****
太吊了,反正我不会 /* HDU 4035 dp求期望的题. 题意: 有n个房间,由n-1条隧道连通起来,实际上就形成了一棵树, 从结点1出发,开始走,在每个结点i都有3种可能: 1.被杀死,回到结点 ...
- hdu 4044 2011北京赛区网络赛E 树形dp ****
专题训练 #include<stdio.h> #include<iostream> #include<string.h> #include<algorithm ...
- hdu 4050 2011北京赛区网络赛K 概率dp ***
题目:给出1-n连续的方格,从0开始,每一个格子有4个状态,左右脚交替,向右跳,而且每一步的步长必须在给定的区间之内.当跳出n个格子或者没有格子可以跳的时候就结束了,求出游戏的期望步数 0:表示不能到 ...
- hdu 4049 2011北京赛区网络赛J 状压dp ***
cl少用在for循环里 #include<cstdio> #include<iostream> #include<algorithm> #include<cs ...
- hdu 4045 2011北京赛区网络赛F 组合数+斯特林数 ***
插板法基础知识 斯特林数见百科 #include<iostream> #include<cmath> #include<cstdio> #include<cs ...
随机推荐
- 新型序列化类库MessagePack,比JSON更快、更小的格式
MessagePack is an efficient binary serialization format. It lets you exchange data among multiple la ...
- 树形dp汇总
HDU 1520 HDU 2196 Codeforces 219D POJ 1155
- Javascript 面向对象
面向对象语言的标识:类的概念. ECMAScript中没有类的概念,因此他的对象与基于类的语言中的对象有所不同. ECMA-262把对象定义为:无序属性的集合,其属性可以包含基本值.对象.函数.我们可 ...
- switch/ifelse 使用总结
2015年3月30日 14:12:36 switch 中的 default 和 if/else 中最后的 else 尽可能的不要用 1. 不要default, 不要写默认处理逻辑, default ...
- 5.nodejs权威指南--HTTP
1. HTTP 1.1 服务器 var http = require('http'); var server = http.createServer(function(req,rsp){ req.on ...
- Java for LeetCode 213 House Robber II
Note: This is an extension of House Robber. After robbing those houses on that street, the thief has ...
- Python字符编码
http://www.runoob.com/python/python-strings.html ASCII Unicode UTF-8 # -*- coding: utf-8 -*- 格式化 %运算 ...
- IIS 4.0配置
neHandler” 今天安装了windows7 开发web项目需要安装IIS,当安装完以后,web程序已经映射到了本地IIS上,运行出现如下错误提示 处理程序“PageHandlerFactor ...
- 【leetcode】Reverse Bits(middle)
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- CCF 节日
问题描述 有一类节日的日期并不是固定的,而是以"a月的第b个星期c"的形式定下来的,比如说母亲节就定为每年的五月的第二个星期日. 现在,给你a,b,c和y1, y2(1850 ≤ ...