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

 #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. JS中删除字符串中的空格

    问题描述:         在进行字符串操作时,由于字符串中存在较多的空格,因此需要考虑取消字符串中的空格 问题解决:       (1)删除字符串中的前导空格(字符串的前面的空格): 注意:这里使用 ...

  2. BestCoder Round #2

    TIANKENG’s restaurant http://acm.hdu.edu.cn/showproblem.php?pid=4883 竟然暴力1.44*10^7  还要*T=100  竟然过了 # ...

  3. State of Hyperparameter Selection

    State of Hyperparameter Selection DANIEL SALTIEL VIEW NOTEBOOK Historically hyperparameter determina ...

  4. 原 Linux搭建SVN 服务器2

    原 Linux搭建SVN 服务器 发表于1年前(2014-08-05 17:55)   阅读(12257) | 评论(3) 31人收藏此文章, 我要收藏 赞3 摘要 Linux搭建SVN 服务器 目录 ...

  5. 管道命令xargs

    在研究hadoop的过程中,遇到一个小难题. 问题描述:我需要将文件夹A下的文件拷贝到文件夹B中,但是以hadoop开头的文件不要拷贝. 问题解决:ls  A|grep -v hadoop|xargs ...

  6. 你所不知道的黑客工具之 EK 篇

    EK(Exploit kits)是指一套利用恶意软件感染用户电脑发起攻击的黑客工具,时下最著名的有 Angler EK.Fiesta EK.Hanjuan EK.Nuclear EK.Neutrino ...

  7. AIZU 0005

    GCD and LCM Time Limit : 1 sec, Memory Limit : 65536 KB Japanese version is here GCD and LCM Write a ...

  8. ubantu安装jdk来配置hadoop

    1.将jdk-7u5-linux-x64.tar.gz拷贝到/usr/lib/jdk/目录下面,这里如果没有jdk文件夹,则创建该文件夹,命令: sudo mkdir jdk //创建文件夹jdk s ...

  9. Spark Mllib逻辑回归算法分析

    原创文章,转载请注明: 转载自http://www.cnblogs.com/tovin/p/3816289.html 本文以spark 1.0.0版本MLlib算法为准进行分析 一.代码结构 逻辑回归 ...

  10. Linux shell 脚本小记

    if结构 #!/bin/env bash -gt ] then echo "$1 is positive" -lt ] then echo "$1 is negative ...