BZOJ1170: [Balkan2007]Cipher|hash
来源:互联网 发布:本科毕业论文 知乎 编辑:程序博客网 时间:2024/06/06 13:11
什么傻逼题..没人做果然都是明智的选择……
让我们来看一下po姐既视感……
一开始写的自然溢出 结果OLE 以为是自然溢出被卡掉了于是写了双取模…… 结果还是OLE
最后发现尼玛这题读入坑爹……字符串里有空格不说,满满的不可见字符是咋回事……
记住不要用scanf读入……可以用gets,或者fread,注意要把一开始的回车过滤掉
getchar读进来全是错的 不知道怎么回事……
–byPoPoQQQ
做法很简单就是二维hash,然后排序找众数..
傻逼读入..傻逼读入..傻逼读入..毁我青春,颓我精神,耗我钱财…
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<queue> #include<set> #include<map> #include<vector> #include<algorithm> #include<iostream> #define ll unsigned long longusing namespace std;struct W{int x,y;ll v;}a[1000010];char s[1111][1111];ll h[1111][1111],l[1111][1111],H,L,ans;int n,m,x,y,c,mx,now,X,Y;bool cmp(W a,W b){ if(a.v==b.v)return a.x==b.x?a.y<b.y:a.x<b.x; return a.v<b.v;}int main(){ cin>>n>>m; gets(s[0]); for(int i=1;i<=n;i++)gets(s[i]+1); //for(int i=1;i<=n;i++) //scanf("%s",s[i]+1); cin>>x>>y; H=1;for(int i=1;i<=y;i++)H*=131; L=1;for(int i=1;i<=x;i++)L*=197; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++)h[i][j]=h[i][j-1]*131+s[i][j]; for(int j=m;j>=y;j--)h[i][j]=h[i][j]-H*h[i][j-y]; } for(int i=y;i<=m;i++) { for(int j=1;j<=n;j++)l[j][i]=l[j-1][i]*197+h[j][i]; for(int j=n;j>=x;j--) { c++; a[c].x=j-x+1; a[c].y=i-y+1; a[c].v=l[j][i]-l[j-x][i]*L; //cout << a[c].x<<" "<< a[c].y <<" "<<a[c].v<< endl; } } sort(a+1,a+c+1,cmp); for(int i=1;i<=c;i++) if(a[i].v!=a[i+1].v) { now++; if(now>mx)mx=now,ans=a[i].v,X=a[i].x,Y=a[i].y; now=0; } else now++; cout << x <<" "<< y << endl; for(int i=0;i<x;i++) { for(int j=0;j<y;j++)putchar(s[X+i][Y+j]); puts(""); } cout<<mx<<endl; int flag=0; for(int i=1;i<=c;i++) if(a[i].v==ans) printf("%d %d\n",a[i].x,a[i].y); return 0;}
0 0
- BZOJ1170: [Balkan2007]Cipher|hash
- BZOJ1170 Balkan2007 Cipher
- BZOJ 1170 [Balkan2007]Cipher Hash
- LA_3213Ancient Cipher( 排序,hash )
- Cipher
- Cipher
- Cipher
- cipher
- 【Balkan2007】Mokia
- 【BZOJ 1176】 [Balkan2007]Mokia
- bzoj 1176: [Balkan2007]Mokia
- 1176: [Balkan2007]Mokia
- [BZOJ1176] [Balkan2007]Mokia
- BZOJ1173 Balkan2007 Point
- 【bzoj1176】[Balkan2007]Mokia
- bzoj1176: [Balkan2007]Mokia
- bzoj1176【Balkan2007】Mokia
- BZOJ 1172 Balkan2007 Dream
- zstu 2532 hdu 1466 计算直线的交点数
- erlang趣事四
- MFC函数简单解释(更新至28日凌晨)
- iOS-UI-基本控件之UILabel
- LeetCode 32 - Longest Valid Parentheses
- BZOJ1170: [Balkan2007]Cipher|hash
- 要出发公司笔试题
- POJ 3368 Frequent values (RMQ)
- Nginx学习笔记七Nginx的Web缓存服务
- 类和对象
- delphi中Tlist的使用。
- 【6-6】HBASE的Java接口(2)
- 电脑基础知识:BIOS的含义及功能简介
- android ble 蓝牙4.0多机通讯客户端实现