【HDOJ】3006 The Number of set
数据量这么小,果断状态压缩+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的更多相关文章
- 【HDOJ】3948 The Number of Palindromes
后缀数组求不重复回文子串数目.注意dp数组. /* 3948 */ #include <iostream> #include <sstream> #include <st ...
- 【HDOJ】4162 Shape Number
循环串的最小表示法. /* */ #include <iostream> #include <string> #include <map> #include < ...
- 【HDOJ】1018 Big Number
数学题,还是使用log避免大数,但是不要忘记需要+1,因为0也是1位,log(100)= 2,但却是3位. #include <stdio.h> #include <math.h&g ...
- 【HDOJ】5179 beautiful number
DFS. /* 5179 */ #include <iostream> #include <algorithm> #include <map> #include & ...
- 【转】oracle数据库NUMBER数据类型
原文:http://www.jb51.net/article/37633.htm NUMBER ( precision, scale)a) precision表示数字中的有效位;如果没有指定prec ...
- 【CF245H】Queries for Number of Palindromes(回文树)
[CF245H]Queries for Number of Palindromes(回文树) 题面 洛谷 题解 回文树,很类似原来一道后缀自动机的题目 后缀自动机那道题 看到\(n\)的范围很小,但是 ...
- 【BZOJ4026】dC Loves Number Theory 分解质因数+主席树
[BZOJ4026]dC Loves Number Theory Description dC 在秒了BZOJ 上所有的数论题后,感觉萌萌哒,想出了这么一道水题,来拯救日益枯竭的水题资源. 给 ...
- 【LeetCode】375. Guess Number Higher or Lower II 解题报告(Python)
[LeetCode]375. Guess Number Higher or Lower II 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://f ...
- 【LeetCode】137. Single Number II 解题报告(Python)
[LeetCode]137. Single Number II 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/single- ...
随机推荐
- VS中新建网站和新建项目web应用程序的区别?(实际应用总结一点)
1,在网站中是没有命名空间namespace这个概念的.例如公共类只有放在App_Code里(不但是公共类,所有的类都应放在这里),其他的类或者页面才可以引用.有using这个概念,但没有namesp ...
- linux根下目录详解及分区建议
/ 根目录 分区大小一定要充足,一般不小于5GB/bin,/usr/bin 普通用户使用命令 建议和/放一起/sbin,/usr/sbin 管理员使用命令/bin,/sbin 操作系统自身 ...
- 使用Windows的NAT功能
使用管理员权限打开命令行控制台. 端口映射相关命令 查看当前机器的端口代理表: netsh interface portproxy show all C:\WINDOWS\system32>ne ...
- Jquery Call WebDav
最近研究了一下WebDav,尝试了一下用Jquery.ajax 发生请求访问WebDav. 代码如下: <!DOCTYPE html> <html xmlns="http: ...
- [Unity官方文档翻译]ScrollRect
官方地址:http://docs.unity3d.com/Manual/script-ScrollRect.html 一边学习一边翻译不知效率如何= = Scroll Rect 在小区域里展示大量内容 ...
- 局域网之php项目IP访问共享
局域网之php本地项目共享 该文章主要介绍本地php项目在局域网内的共享访问,主要体现为通过本地ip地址访问项目 做法如下: 1.更改本地盘host文件(winds目录为:C:\Windows\Sys ...
- vs2015中ctrl+shift+F进行“在文件中查找”,有时候无效?
搜狗拼音的默认简繁切换快捷键是ctrl+shift+F,改掉以后vs就可以收到这个按键消息了
- plsql中文乱码问题(显示问号)
问题:打开plsql,执行sql语句,中文显示乱码: 解决方案: 输入sql语句select userenv('language') from dual查看数据库字符集 输入sql语句select * ...
- 一步一步建MVC
http://www.cnblogs.com/yuangang/p/5569518.html
- How to hanganalyze and systemstate dumps
Oracle support request hang analysis and system state dumps when rasing SR. One 10.1 or higher versi ...