数据量这么小,果断状态压缩+dp。

 /* 3006 */
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <deque>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <cctype>
#include <cassert>
#include <functional>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,1024000") #define mpii map<int,int>
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define rep(i, a, n) for (int i=a;i<n;++i)
#define per(i, a, n) for (int i=n-1;i>=a;--i)
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define lson l, mid, rt<<1
#define rson mid+1, r, rt<<1|1 const int N = ;
const int maxn = (<<)+;
bool visit[maxn];
int sft[]; int main() {
ios::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif int n, m;
int x, nn;
int ans, tmp; sft[] = ;
rep(i, , )
sft[i] = sft[i-] << ; memset(visit, false, sizeof(visit));
while (scanf("%d %d", &n, &m)!=EOF) {
memset(visit, false, sizeof(visit));
visit[] = true;
rep(i, , n) {
scanf("%d", &nn);
tmp = ;
while (nn--) {
scanf("%d", &x);
tmp |= sft[x];
}
per(j, , maxn) {
if (visit[j]) {
visit[j|tmp] = true;
}
}
} ans = ;
rep(j, , maxn)
ans += visit[j];
printf("%d\n", ans);
} #ifndef ONLINE_JUDGE
printf("time = %d.\n", (int)clock());
#endif return ;
}

【HDOJ】3006 The Number of set的更多相关文章

  1. 【HDOJ】3948 The Number of Palindromes

    后缀数组求不重复回文子串数目.注意dp数组. /* 3948 */ #include <iostream> #include <sstream> #include <st ...

  2. 【HDOJ】4162 Shape Number

    循环串的最小表示法. /* */ #include <iostream> #include <string> #include <map> #include < ...

  3. 【HDOJ】1018 Big Number

    数学题,还是使用log避免大数,但是不要忘记需要+1,因为0也是1位,log(100)= 2,但却是3位. #include <stdio.h> #include <math.h&g ...

  4. 【HDOJ】5179 beautiful number

    DFS. /* 5179 */ #include <iostream> #include <algorithm> #include <map> #include & ...

  5. 【转】oracle数据库NUMBER数据类型

    原文:http://www.jb51.net/article/37633.htm NUMBER ( precision, scale)a)  precision表示数字中的有效位;如果没有指定prec ...

  6. 【CF245H】Queries for Number of Palindromes(回文树)

    [CF245H]Queries for Number of Palindromes(回文树) 题面 洛谷 题解 回文树,很类似原来一道后缀自动机的题目 后缀自动机那道题 看到\(n\)的范围很小,但是 ...

  7. 【BZOJ4026】dC Loves Number Theory 分解质因数+主席树

    [BZOJ4026]dC Loves Number Theory Description  dC 在秒了BZOJ 上所有的数论题后,感觉萌萌哒,想出了这么一道水题,来拯救日益枯竭的水题资源.    给 ...

  8. 【LeetCode】375. Guess Number Higher or Lower II 解题报告(Python)

    [LeetCode]375. Guess Number Higher or Lower II 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://f ...

  9. 【LeetCode】137. Single Number II 解题报告(Python)

    [LeetCode]137. Single Number II 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/single- ...

随机推荐

  1. mybatis根据property获取column

    mybatis根据property获取column mybatis根据类的属性获取xml文件中对应的column mybatis获取xml文件中property对应的column >>&g ...

  2. webstorm 如何配置git

    2016-09-22 15:00:25 补充js 操作后 发现工具自动生成了两个文件,如果提交到git上 会造成不必要的麻烦,看看怎么去掉产生这个的原因吧! 去掉对应的监听:http://fronte ...

  3. sqlserver 自定义字符串分割函数.

    --SQL Server Split函数 --Author: sq --说明:被分割后的字段为:short_str --支持分割符多字节 --使用方法 --Select * FROM splits(' ...

  4. (转)Asp.net的HttpCookie写入汉字读取时为乱...

    今天有个问我:在Asp.net的HttpCookie中写入汉字,读取值为什么全是乱码?其实这是因为文字编码而造成的,汉字是两个编码,所以才会搞出这么个乱码出来!其实解决的方法很简单:只要在写入Cook ...

  5. OPENQUERY

    SELECT * FROM OPENQUERY(saql007,' SELECT  col1,col2,col3 FROM dbname.shemaname.tablename WHERE  (1=1 ...

  6. hibernate - 何时关闭数据库

    ref: http://www.coderanch.com/t/637103/ORM/databases/close-database-connection-hibernate 我上这个问题, 原因是 ...

  7. SQL输出矩阵

    数据库环境:SQL SERVER2008R2 需求:用SQL实现如下2个图中的矩阵.            图1和图2都是行列转换的另一个变形,下面直接贴上SQL脚本. 图1的SQL实现 /*利用系统 ...

  8. 网页快照 - C#实现

    /// <summary> /// 图片类型枚举 /// </summary> public enum ImageType { GIF = , JPG = , PNG = } ...

  9. SQL数据库的备份和恢复

    SQL数据库的备份和恢复 一.SQL数据库的备份: 1.依次打开 开始菜单 → 程序 → Microsoft SQL Server 2008 → SQL Server Management Studi ...

  10. java静态代理,动态代理,cglib代理

    代理模式在我们的应用中是很常见的,例如拦截器,spring的事务管理等.之所以能被代理,是因为java允许我们通过反射机制动态构造目标对象,并调用相应的方法. 就好像拿到了目标对象的引用,自然可以在目 ...