暴力水过,剪一下枝= =果断是数据水了

 #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的更多相关文章

  1. hdu 4691 Front compression (后缀数组)

    hdu 4691 Front compression 题意:很简单的,就是给一个字符串,然后给出n个区间,输出两个ans,一个是所有区间的长度和,另一个是区间i跟区间i-1的最长公共前缀的长度的数值的 ...

  2. HDU 4691 Front compression (2013多校9 1006题 后缀数组)

    Front compression Time Limit: 5000/5000 MS (Java/Others)    Memory Limit: 102400/102400 K (Java/Othe ...

  3. HDU 4691 Front compression(后缀数组)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4691 题意:给出Input,求出Compressed output.输出各用多少字节. 思路:求后缀数 ...

  4. 【HDOJ】4691 Front compression

    后缀数组基础题目,dc3解. /* 4691 */ #include <iostream> #include <sstream> #include <string> ...

  5. hdu4691 Front compression(后缀数组)

    Front compression Time Limit: 5000/5000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others) ...

  6. hdu4691 Front compression ——暴力 || 后缀数组

    link:http://acm.hdu.edu.cn/showproblem.php?pid=4691 暴力,数据明显太水了吧,n=10^5, O(n^2)的复杂度哎喂.想让大家暴力写直接让n=100 ...

  7. HDU-4691 Front compression 后缀数组

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4691 后缀数组模板题,求出Height数组后,对Height做RMQ,然后直接统计就可以了... // ...

  8. hdu 4691 最长的共同前缀 后缀数组 +lcp+rmq

    http://acm.hdu.edu.cn/showproblem.php? pid=4691 去年夏天,更多的学校的种族称号.当时,没有后缀数组 今天将是,事实上,自己的后缀阵列组合rmq或到,但是 ...

  9. HDU 4691

    http://acm.hdu.edu.cn/showproblem.php?pid=4691 留个板子. #include <iostream> #include <cstdio&g ...

随机推荐

  1. 【转载】VMWare ESXi 5.0和vSphere Client安装和配置

      免责声明:     本文转自网络文章,转载此文章仅为个人收藏,分享知识,如有侵权,请联系博主进行删除.     原文作者:张洪洋_     原文地址:http://blog.sina.com.cn ...

  2. 【BZOJ】【1026】【SCOI2009】Windy数

    数位DP cxlove基础数位DP第三题 = =预处理是个很有用的东西!然后就是分类讨论! /***************************************************** ...

  3. SqlBulkCopy 简单运用

    using(SqlConnection conn = new SqlConnection(str)) { conn.Open(); using (System.Data.SqlClient.SqlBu ...

  4. [转载]Spring Java Based Configuration

    @Configuration & @Bean Annotations Annotating a class with the @Configuration indicates that the ...

  5. 求和问题总结(leetcode 2Sum, 3Sum, 4Sum, K Sum)

    转自  http://tech-wonderland.net/blog/summary-of-ksum-problems.html 前言: 做过leetcode的人都知道, 里面有2sum, 3sum ...

  6. HDU 3507 Print Article(斜率优化DP)

    题目链接 题意 : 一篇文章有n个单词,如果每行打印k个单词,那这行的花费是,问你怎么安排能够得到最小花费,输出最小花费. 思路 : 一开始想的简单了以为是背包,后来才知道是斜率优化DP,然后看了网上 ...

  7. http://blog.csdn.net/superhosts/article/details/15813247

    http://blog.csdn.net/superhosts/article/details/15813247

  8. 包含中文的字符串中截取前N个字符

    package com.wangzhu.string; import java.io.UnsupportedEncodingException; public class SubStringDemo1 ...

  9. java nio知识点总结

    1.NIO是Java 4里面提供的新的API,目的是用来解决传统IO的问题.是用来解决传统io的问题的. 用来解决传统io的问题的.用来解决传统io的问题.阻塞的. 2.传统IO中,Stream是单向 ...

  10. HTML5 编辑 API 之 Range 对象(二)

    1.Range.cloneContents()The Range.cloneContents() returns a DocumentFragment copying the objects of t ...