hdu2146

/*
分析:
    hash。
    字典树TLE,各种优化无果= =III。。。函数调用真的
很消耗时间额。。。不过给的字符串全是01串、且长度不
超过60个,这是不是和64位整形有点儿像呀,所以。。。
方法呼之欲出了吧 →_→ 。
    刚开始968MS险过。。就这样搁那儿不是咱风格~,优化
之~,453MS。

                                        2013-04-21
*/





#include"iostream"
#include"cstdio"
#include"cstring"
#include"algorithm"
using namespace std;
int n,L,K,tot;
__int64 hash[60*1011];
int main()
{
	int i,l;
	int limit;
	__int64 temp,base;
	char str[66];
	while(scanf("%d%d%d",&n,&L,&K)!=-1)
	{
		tot=0;
		limit=L-K;
		base=((__int64)1<<(K-1))-1;
		for(i=0;i<n;i++)
		{
			scanf("%s",str);
			temp=0;
			for(l=0;l<K;l++)	temp=(temp<<1)+str[l]-'0';
			hash[tot++]=temp;
			for(l=1;l<=limit;l++)
			{
				temp=((temp&base)<<1)+str[l+K-1]-'0';
				hash[tot++]=temp;
			}
		}
		sort(hash,hash+tot);

		int ans,cnt,pre;
		cnt=ans=0;
		pre=-11;
		hash[tot]=-1;
		for(i=0;i<=tot;i++)
		{
			if(hash[i]!=pre)
			{
				if(cnt>ans)	ans=cnt;
				cnt=1;
				pre=hash[i];
			}
			else	cnt++;
		}
		cout<<ans<<endl;
	}
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值