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

  1. /* 3006 */
  2. #include <iostream>
  3. #include <string>
  4. #include <map>
  5. #include <queue>
  6. #include <set>
  7. #include <stack>
  8. #include <vector>
  9. #include <deque>
  10. #include <algorithm>
  11. #include <cstdio>
  12. #include <cmath>
  13. #include <ctime>
  14. #include <cstring>
  15. #include <climits>
  16. #include <cctype>
  17. #include <cassert>
  18. #include <functional>
  19. using namespace std;
  20. //#pragma comment(linker,"/STACK:102400000,1024000")
  21.  
  22. #define mpii map<int,int>
  23. #define vi vector<int>
  24. #define pii pair<int,int>
  25. #define vpii vector<pair<int,int> >
  26. #define rep(i, a, n) for (int i=a;i<n;++i)
  27. #define per(i, a, n) for (int i=n-1;i>=a;--i)
  28. #define pb push_back
  29. #define mp make_pair
  30. #define fir first
  31. #define sec second
  32. #define all(x) (x).begin(),(x).end()
  33. #define SZ(x) ((int)(x).size())
  34. #define lson l, mid, rt<<1
  35. #define rson mid+1, r, rt<<1|1
  36.  
  37. const int N = ;
  38. const int maxn = (<<)+;
  39. bool visit[maxn];
  40. int sft[];
  41.  
  42. int main() {
  43. ios::sync_with_stdio(false);
  44. #ifndef ONLINE_JUDGE
  45. freopen("data.in", "r", stdin);
  46. freopen("data.out", "w", stdout);
  47. #endif
  48.  
  49. int n, m;
  50. int x, nn;
  51. int ans, tmp;
  52.  
  53. sft[] = ;
  54. rep(i, , )
  55. sft[i] = sft[i-] << ;
  56.  
  57. memset(visit, false, sizeof(visit));
  58. while (scanf("%d %d", &n, &m)!=EOF) {
  59. memset(visit, false, sizeof(visit));
  60. visit[] = true;
  61. rep(i, , n) {
  62. scanf("%d", &nn);
  63. tmp = ;
  64. while (nn--) {
  65. scanf("%d", &x);
  66. tmp |= sft[x];
  67. }
  68. per(j, , maxn) {
  69. if (visit[j]) {
  70. visit[j|tmp] = true;
  71. }
  72. }
  73. }
  74.  
  75. ans = ;
  76. rep(j, , maxn)
  77. ans += visit[j];
  78. printf("%d\n", ans);
  79. }
  80.  
  81. #ifndef ONLINE_JUDGE
  82. printf("time = %d.\n", (int)clock());
  83. #endif
  84.  
  85. return ;
  86. }

【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. app抓包

    http://www.360doc.com/content/14/1126/11/9200790_428168701.shtml 记得下载证书  不然有些网站是抓不到的

  2. css动画结束后 js无法修改translated值 .

    由于项目的需要,俺要做一些页面的转场动画. 即将是移动端,肯定是首先css动画了. 结果确发现,css动画中,如果设置animation-fill-mode: both;在动画结束后无法个性trans ...

  3. React+Immutable.js的心路历程

    这段时间做的项目开发中用的是React+Redux+ImmutableJs+Es6开发,总结了immutable.js的相关使用姿势: Immutable Data 顾名思义是指一旦被创造后,就不可以 ...

  4. WCF学习笔记一(概述)

    WCF  Windows Communication Foundation 分布式通信框架.WCF是对现有分布式通信技术的整合.是各种分布式计算的集大成者.主要整合技术如下图: WCF的服务不能孤立的 ...

  5. 消息中间件MQ基础理论知识

    欢迎转载,转载请注明出处:http://www.cnblogs.com/lidabnu/p/5723280.html 消息中间件已经流行很长时间,一般情况下,不需要自己来从头研发.设计消息中间件,所以 ...

  6. ubuntu 13.04 xrdp 远程桌面连接问题[转载]

    本人ubuntu12.04,遇到了同样的问题,用一下方法解决了,mark一下. ubuntu 13.04 xrdp 远程桌面连接问题. win 7 远程桌面连接 ubuntu desktop 有几种办 ...

  7. MVC权限模块

    设计方向: 1.摒弃SiteMap,避免在容易书写错误的sitemap中书写,导航在controller和action上打标签生成. 2.controller统一继承basecontroller,在b ...

  8. 输出第N个素数

    输出第N个素数 public class FindNthPrime { public static void main(String[] args){ int N = Integer.parseInt ...

  9. iframe中的各种跳转方法(转)

    一.背景A,B,C,D都是jsp,D是C的iframe,C是B的iframe,B是A的iframe,在D中跳转页面的写法区别如下. 二.JS跳转window.location.href.locatio ...

  10. Android学习4—短信发送器的实现

    界面预览: 由图中可以看出,此APP需要的组件有:两个TextView,一个用于显示手机号码的标题,另一个用于显示短信内容的标题.                                    ...