显示代码纯文本
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<map>
#include<set>
using namespace std;
int A,B,n;
vector<int> s;
int len_lb[]={0,1,2,4,8,16,32,64,128,256,512,1024,2048,4096};
class WORD{
public:
int tx;//表示那个01序列
int tm;//出现次数
int len;//长度
void output_tx(void){
int i;
for(i=len;i>=1;i--) printf("%d",tx>>(i-1)&1);
}
};
bool operator < (WORD a,WORD b){
if(a.tm>b.tm) return true;
if(a.tm<b.tm) return false;
if(a.len<b.len) return true;
if(a.len>b.len) return false;
if(a.tx<b.tx) return true;
if(a.tx>b.tx) return false;
return false;
}
int p[13][5000]={0};
void deal(int k){//统计长度为k的比特序列
int i;
int now=0;
for(i=0;i<s.size();i++){
now=now&(~len_lb[k]);
now<<=1;now+=s[i];
if(i>=k-1){
p[k][now]++;
}
}
}
vector<WORD> ans;
void stat(void){
int i,j;
int high;
for(i=A;i<=B;i++){
high=(1<<i)-1;
for(j=0;j<=high;j++){
ans.push_back((WORD){j,p[i][j],i});
}
}
sort(ans.begin(),ans.end());
}
void work(void){
int i;
for(i=A;i<=B;i++) deal(i);
stat();
int temp;
int nump=0;
for(i=0;i<ans.size()&&nump<=n;i++){
if(i==0||ans[i].tm!=ans[i-1].tm){//新开一个频率
temp=1;
nump++;
if(nump>n||ans[i].tm==0) break;
if(i) printf("\n");
printf("%d\n",ans[i].tm);//打印这个频率
ans[i].output_tx();printf(" ");
}
else{//接着上面的频率
if(temp%6==0) printf("\n");
ans[i].output_tx();printf(" ");
temp++;
}
}
}
void read(void){
scanf("%d%d%d",&A,&B,&n);
char ch;
while(scanf("%c",&ch)!=EOF){
if(ch=='0') s.push_back(0);
else if(ch=='1') s.push_back(1);
}
}
int main(){
freopen("contact.in","r",stdin);
freopen("contact.out","w",stdout);
read();
work();
return 0;
}