hdu 4691 Front compression
暴力水过,剪一下枝= =果断是数据水了
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL __int64
using namespace std; const int MAXN=;
char str[MAXN]; int same(int a,int b,int x,int y)
{
if(a==x)
return min(b,y)-a;
int i=;
while((a+i)<b&&(x+i)<y&&str[a+i]==str[x+i])
i++;
return i;
} int num(int x)
{
if(!x)return ;
int ans=;
while(x!=)
{
ans++;
x/=;
}
return ans;
} int main()
{
int n,a,b,x,y,q,p;
while(~scanf("%s",str))
{
scanf("%d",&n);
LL s,t;
s=t=;
for(int i=;i<n;i++)
{
scanf("%d%d",&a,&b);
if(i!=)q=same(a,b,x,y);
else q=;
p=num(q);
s+=b-a+;
t+=p++b-a-q+;
x=a;y=b;
}
printf("%I64d %I64d\n",s,t);
}
return ;
}
hdu 4691 Front compression的更多相关文章
- hdu 4691 Front compression (后缀数组)
hdu 4691 Front compression 题意:很简单的,就是给一个字符串,然后给出n个区间,输出两个ans,一个是所有区间的长度和,另一个是区间i跟区间i-1的最长公共前缀的长度的数值的 ...
- HDU 4691 Front compression (2013多校9 1006题 后缀数组)
Front compression Time Limit: 5000/5000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Othe ...
- HDU 4691 Front compression(后缀数组)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4691 题意:给出Input,求出Compressed output.输出各用多少字节. 思路:求后缀数 ...
- 【HDOJ】4691 Front compression
后缀数组基础题目,dc3解. /* 4691 */ #include <iostream> #include <sstream> #include <string> ...
- hdu4691 Front compression(后缀数组)
Front compression Time Limit: 5000/5000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others) ...
- hdu4691 Front compression ——暴力 || 后缀数组
link:http://acm.hdu.edu.cn/showproblem.php?pid=4691 暴力,数据明显太水了吧,n=10^5, O(n^2)的复杂度哎喂.想让大家暴力写直接让n=100 ...
- HDU-4691 Front compression 后缀数组
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4691 后缀数组模板题,求出Height数组后,对Height做RMQ,然后直接统计就可以了... // ...
- hdu 4691 最长的共同前缀 后缀数组 +lcp+rmq
http://acm.hdu.edu.cn/showproblem.php? pid=4691 去年夏天,更多的学校的种族称号.当时,没有后缀数组 今天将是,事实上,自己的后缀阵列组合rmq或到,但是 ...
- HDU 4691
http://acm.hdu.edu.cn/showproblem.php?pid=4691 留个板子. #include <iostream> #include <cstdio&g ...
随机推荐
- diahosting的低配vps弱爆了
以下仅为一个用户的心声 上年年中的时候买了dia的128M vps,算是我第一个vps.工作以来,我弄了一个wp博客,所以我在上面搭了apache的服务器,但是由于内存低,挂得也快.后来我换了Ngin ...
- BZOJ 2763: [JLOI2011]飞行路线 spfa dp
题目链接: http://www.lydsy.com/JudgeOnline/problem.php?id=2763 题解: d[x][kk]表示从s到x用了kk次免费机会的最少花费. 代码: #in ...
- SqlServer 系统存储过程
exec sp_databases; --查看数据库exec sp_tables; --查看表exec sp_columns Categories;--查看列exec sp_helpIndex Cat ...
- HTML5网页制作教程:HTML5块级链接
网页制作Webjx文章简介:Web 标准中处处充满了打脸行为,这条规则现在已经失效了!在那篇文章发布一个月后,HTML5doctor 发表了 “Block-level” links in HTML5, ...
- sampler2d
Here is the syntax for a sampler in Direct3D 9. sampler Name = SamplerType{ Texture = <texture_ ...
- hibernate Session
转: http://kayo.iteye.com/blog/204143 Session 接口 Session 接口对于Hibernate 开发人员来说是一个最重要的接口.然而在Hibernate 中 ...
- hdu 4901
一个简单的dp,比赛的时候太坚信自己的小聪明没用二维数组一直WA到死: #include<cstdio> #include<cstring> #define maxn 1009 ...
- ural 1864
题意描述不清 而且还卡精度 ~~ #include <cstdio> #include <cstring> #include <iostream> using ...
- JS内存管理测试
打开调试器,切换到timer,点击左下角的record按钮开始,切换到memory视图,在文档中点击鼠标左右键,看股价走势图 function Allocate(kbs){ this.mem = ne ...
- centos在yum install报错:Another app is currently holding the yum lock解决方法
centos在yum install报错:Another app is currently holding the yum lock,这个问题可能是很多的新手经常遇到问题,之前也有人问我,包括本人在刚 ...