2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 M. Frequent Subsets Problem
来源:互联网 发布:淘宝上怎么买到电视棒 编辑:程序博客网 时间:2024/05/21 10:14
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
题目来源
2017 ACM-ICPC 亚洲区(南宁赛区)网络赛
题意:给你一个N和a,所有U的子集里(U={1,2,3,4,...N}),有多少个是频繁子集。频繁子集就是给定M个集合,该子集被这些集合包含的次数要大于 a*M。
解题思路:一开始没注意N最大20……瞎几把搞……一直搞不出来……后来发现之后……直接暴力状压就可以了………我甚至怀疑直接用stl里的set都能过。
#include<iostream>#include<algorithm>#include<math.h>using namespace std;typedef long long int ll;int S[100];//给你的集合int main(){ int m=0; int n; double a; scanf("%d%lf",&n,&a); int num; char ch; while(~scanf("%d%c",&num,&ch)) { S[m]+=(1<<(num-1)); if(ch=='\n') m++; } int ans=0; int nnum=ceil(m*a); //枚举所有子集 for(int i=1;i<(1<<n);i++) { double sum=0; for(int j=0;j<m;j++) { if((i&S[j])==i) sum++; } if(sum>=nnum) ans++; } printf("%d\n",ans); 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)
- 列表组件的运用
- 9-24NOIP模拟赛总结
- RMI不支持远程注册(绑定)
- 如何屏蔽RecyclerView单边滑动到头阴影(fadingEdge)
- 反向传播手记
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 M. Frequent Subsets Problem
- listview的混乱处理---设置moudle属性
- 进程-线程
- 用c语言实现顺序表
- javascript 搜索算法(Search)说明
- MFC_组合框,列表框
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 G. Finding the Radius for an Inserted Circle(计算几何,二分)
- 网易编程题之地牢逃脱
- iOS【SwiftyJSON的常用方式】