bzoj 3555 企鹅QQ
https://www.lydsy.com/JudgeOnline/problem.php?id=3555
枚举每一位字符,计算字符两侧的哈希值,然后进行比较,用map或排序记录出与其相同的字符串数量。
时间复杂度O(nlogn)
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdio>
using namespace std;
#define LL long long
#define N int(3e4+2)
#define M int(2e2+2)
#define base1 233
#define base2 211
int n,m,l,ans;
char s[M];
unsigned long long temp[N],before[N][M],behind[N][M];
void work(int x)
{
for(int i=;i<=l;i++)before[x][i]=before[x][i-]*+s[i];
for(int i=l;i>=;i--)behind[x][i]=behind[x][i+]*+s[i];
}
int main()
{
scanf("%d%d%d",&n,&l,&m);
for(int i=;i<=n;i++)
{
scanf("%s",s+);
work(i);
}
for(int j=;j<=l;j++)
{
for(int i=;i<=n;i++)temp[i]=before[i][j-]*+behind[i][j+]*;
sort(temp+,temp++n);
int now=;
for(int i=;i<=n;i++)
{
if(temp[i]==temp[i-])ans+=now,now++;
else now=;
}
}
printf("%d",ans);
}
bzoj 3555 企鹅QQ的更多相关文章
- BZOJ 3555: [Ctsc2014]企鹅QQ [字符串哈希]【学习笔记】
3555: [Ctsc2014]企鹅QQ Time Limit: 20 Sec Memory Limit: 256 MBSubmit: 2046 Solved: 749[Submit][Statu ...
- BZOJ 3555: [Ctsc2014]企鹅QQ hash
3555: [Ctsc2014]企鹅QQ Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline/p ...
- bzoj——3555: [Ctsc2014]企鹅QQ
3555: [Ctsc2014]企鹅QQ Time Limit: 20 Sec Memory Limit: 256 MBSubmit: 2617 Solved: 921[Submit][Statu ...
- 字符串Hash || BZOJ 3555: [Ctsc2014]企鹅QQ || P4503 [CTSC2014]企鹅QQ
题面:[CTSC2014]企鹅QQ 题解:无 代码: #include<iostream> #include<cstring> #include<cstdio> # ...
- 3555: [Ctsc2014]企鹅QQ
3555: [Ctsc2014]企鹅QQ Time Limit: 20 Sec Memory Limit: 256 MBSubmit: 696 Solved: 294[Submit][Status ...
- 【BZOJ-3555】企鹅QQ 字符串Hash
3555: [Ctsc2014]企鹅QQ Time Limit: 20 Sec Memory Limit: 256 MBSubmit: 1545 Solved: 593[Submit][Statu ...
- [bzoj3555]企鹅QQ(hash)
3555: [Ctsc2014]企鹅QQ Time Limit: 20 Sec Memory Limit: 256 MBSubmit: 1645 Solved: 616[Submit][Statu ...
- bzoj3555 企鹅QQ
3555: [Ctsc2014]企鹅QQ Time Limit: 20 Sec Memory Limit: 256 MBSubmit: 1640 Solved: 613 Description P ...
- bzoj3555: [Ctsc2014]企鹅QQ
将字符串hash.不难写.然而1.注意用longlong2.数组大小注意...3.似乎别人都用的unsigned long long ?. #include<cstdio> #includ ...
随机推荐
- E20170417-sl
recursive adj.递归的 strategy n.战略
- 洛谷 - P2730 - 魔板 Magic Squares - bfs
写状态转移弄了很久,老了,不记得自己的数组是怎么标号的了. #include <bits/stdc++.h> using namespace std; #define ll long lo ...
- PTA 模拟【string以及字母->数组下标】
假设有九宫格输入法键盘布局如下: [ 1,.?! ] [ 2ABC ] [ 3DEF ] [ 4GHI ] [ 5JKL ] [ 6MNO ] [ 7PQRS ] [ 8TUV ] [ 9WXYZ ] ...
- 安装 statconn 使R与c#交互
很久以前完成过,但是最近重新折腾发现全忘了,所以记下来. 1.安装 R 2.安装 R studio 3.去 http://rcom.univie.ac.at/download.html 下载 stat ...
- Hello world——程序员的第一篇代码
Hello world 是和A+B问题并驾齐驱的一道题,也是当世的经典题之一. 题目: 输出“Hello world” 样例输入 样例输出 Hello world Hello world ...
- Springboot的yml文件
spring: datasource: # 数据库四大组件 schema-password: root data-username: root driver-class-name: com.mysql ...
- Eclipse - Maven项目Update Project后jdk版本变成1.5
问题与分析 最近遇到个奇怪的问题,在Eclipse里对一个Maven项目进行Update Project(快捷键是 Alt+F5),原本jdk为1.8的项目忽然就变成了1.5,于是就报了一些错误. 我 ...
- 关于 typedef struct 和 struct
举个例子说明:typedef struct abc{ int x; int y; int z;}ABC;是将结构体abc类型重新起个名字为ABC,以后再定义同一类型的变量时,可以写成:ABC m,n; ...
- python之商品操作小程序
要求:写一个添加商品的程序,商品信息写入txt文件中,以二维字典形式比如:{‘小米’:{‘价格’:‘1999元’,‘数量’:10}} 1.添加商品 #商品名称 #价格 #数量 2.查看商品 3.删除商 ...
- AWVS11使用教程——Acunetix Web Vulnerability Scanner 11.x
AWVS11使用教程 一:普通扫描. 二:报告生成. 三:登陆扫描. Acunetix Web Vulnerability Scanner(简称AWVS)是一款知名的网络漏洞扫描工具,它通过网络爬虫测 ...