2017 ACM-ICPC 亚洲区(南宁赛区)网络赛: M. Frequent Subsets Problem(状压)
来源:互联网 发布:枪神纪刷枪软件2017 编辑:程序博客网 时间:2024/05/20 03:47
The frequent subset problem is defined as follows. Suppose U={1, 2,…,N} is the universe, and S1, S2,…,SMare M sets over U. Given a positive constant α, 0<α≤1, a subset B (B≠0) is α-frequent if it is contained in at least αM sets of S1, S2,…,SM, i.e. ∣{i:B⊆Si}∣≥αM. The frequent subset problem is to find all the subsets that are α-frequent. For example, let U={1,2,3,4,5}, M=3, α=0.5, and S1={1,5}, S2={1,2,5}, S3={1,3,4}. Then there are 3 α-frequent subsets of U, which are {1},{5} and {1,5}.
Input Format
The first line contains two numbers N and α, where N is a positive integers, and α is a floating-point number between 0 and 1. Each of the subsequent lines contains a set which consists of a sequence of positive integers separated by blanks, i.e., line i+1 contains Si, 1≤i≤M . Your program should be able to handle N up to 20 and M up to 50.
Output Format
The number of α-frequent subsets.
样例输入
15 0.41 8 14 4 13 23 7 11 610 8 4 29 3 12 7 15 28 3 2 4 5
样例输出
11
#include<bits/stdc++.h>using namespace std;int a[55];int main(){ memset(a,0,sizeof a); int m=0,n; double p; scanf("%d%lf",&n,&p); int num; char ch; while(scanf("%d%c",&num,&ch)!=EOF) { a[m]+=(1<<(num-1)); if(ch=='\n')m++; } int ans=0; int sta=ceil(m*p); for(int i=1;i<(1<<n);i++) { int sum=0; for(int j=0;j<m;j++) { if((i&a[j])==i)sum++; } if(sum>=sta)ans++; } cout<<ans<<endl; return 0;}
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛: M. Frequent Subsets Problem(状压)
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 M. Frequent Subsets Problem
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 M Frequent Subsets Problem
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 M. Frequent Subsets Problem (状态压缩)
- 计蒜客 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 M. Frequent Subsets Problem (位压缩)
- 2017 ACM-ICPC亚洲区(南宁赛区)网络赛 F.Frequent Subsets Problem
- Frequent Subsets Problem 进制运算 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 Frequent Subsets Problem
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛:Frequent Subsets Problem
- 2017ICPC 南宁网络赛M Frequent Subsets Problem
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 M题
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 The Heaviest Non-decreasing Subsequence Problem
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 The Heaviest Non-decreasing Subsequence Problem
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 The Heaviest Non-decreasing Subsequence Problem
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛:The Heaviest Non-decreasing Subsequence Problem
- 2017ACM-ICPC南宁网络赛Frequent Subsets Problem(康托展开+bfs)
- 含有重复字符的全排列问题以及按字典序打印
- 软件开发流程中常用的图形
- Function深入解析一
- [LeetCode] 332. Reconstruct Itinerary
- ucos-iii学习之抢占式调度以及调度点
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛: M. Frequent Subsets Problem(状压)
- 实验一 线性表的基本操作实现及其应用
- view port 与sreen之间的关系
- 回溯法求解数组中和为固定值的所有元素集合
- 二极管钳位电路
- Nginx配置详情-配置说明-参数优化-核心HTTP配置(二)
- 在不按装oracle客户端条件下使用plsql连接oracle数据库
- 简单配置一个Discuz!社区网站
- CF 863B Kayaking【STL+暴力】