HDOJ 4691 Front compression 后缀数组

后缀数组求两子串间的最大公共前缀.

Front compression

Time Limit: 5000/5000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others)
Total Submission(s): 1382 Accepted Submission(s): 517

Problem Description Front compression is a type of delta encoding compression algorithm whereby common prefixes and their lengths are recorded so that they need not be duplicated. For example:
HDOJ 4691 Front compression 后缀数组

The size of the input is 43 bytes, while the size of the compressed output is 40vc3Ryb25nPi4gSGVyZSwgZXZlcnkgc3BhY2UgYW5kIG5ld2xpbmUgaXMgYWxzbyBjb3VudGVkIGFzIDEgYnl0ZS48YnI+CkdpdmVuIHRoZSBpbnB1dCwgZWFjaCBsaW5lIG9mIHdoaWNoIGlzIGEgc3Vic3RyaW5nIG9mIGEgbG9uZyBzdHJpbmcsIHdoYXQgYXJlIHNpemVzIG9mIGl0IGFuZCBjb3JyZXNwb25kaW5nIGNvbXByZXNzZWQgb3V0cHV0PwoKIAo8YnI+CgpJbnB1dAoKVGhlcmUgYXJlIG11bHRpcGxlIHRlc3QgY2FzZXMuIFByb2Nlc3MgdG8gdGhlIEVuZCBvZiBGaWxlLjxicj4KVGhlIGZpcnN0IGxpbmUgb2YgZWFjaCB0ZXN0IGNhc2UgaXMgYSBsb25nIHN0cmluZyBTIG1hZGUgdXAgb2YgbG93ZXJjYXNlIGxldHRlcnMsIHdob3NlIGxlbmd0aCBkb2Vzbg=="t exceed 100,000. The second line contains a integer 1 ≤ N ≤ 100,000, which is the number of lines in the input. Each of the following N lines contains two integers 0 ≤ A Output For each test case, output the sizes of the input and corresponding compressed output.
Sample Input

frcode 2 0 6 0 6 unitedstatesofamerica 3 0 6 0 12 0 21 myxophytamyxopodnabnabbednabbingnabit 6 0 9 9 16 16 19 19 25 25 32 32 37


Sample Output

14 12 42 31 43 40


Author Zejun Wu (watashi)
Source 2013 Multi-University Training Contest 9


#include #include #include #include #include using namespace std; typedef long long int LL; const int maxn=102100; int sa[maxn],rank[maxn],rank2[maxn],h[maxn],c[maxn],*x,*y,ans[maxn]; char str[maxn]; bool cmp(int* r,int a,int b,int l,int n) { if(r[a]==r[b]&&a+l=0;i--) sa[--c[x[y[i]]]]=y[i]; } void get_sa(char c[],int n,int sz=128) { x=rank,y=rank2; for(int i=0;i=len) y[yid++]=sa[i]-len; radix_sort(n,sz); swap(x,y); x[sa[0]]=yid=0; for(int i=1;i=n) break; } for(int i=0;ir) swap(l,r); ///!!!!!if(l==r) return n-sa[l]; int a=l+1,b=r; int k=Log[b-a+1]; return min(dp[a][k],dp[b-(1>a>>b) cout

点击复制链接 与好友分享!回本站首页

您对本文章有什么意见或着疑问吗?请到论坛讨论您的关注和建议是我们前行的参考和动力
上一篇:hdu4000 && hrbust1625
下一篇:NYOJ 325 ZB的生日
相关文章

对于c/c++中的数组排序及计算平均值和

在c/c++中利用数组名和指针进行排序的

C/C++中多维数组的指针作为函数参数传

C/C++中数组和指针类型的关系的入门教

c/c++中的字符指针数组,指向指针的指针

C/C++数组名与指针区别深入探索

c++之字符数组型的静态成员初始化实例

C++ VS C#(5):数组

C++中的动态多维数组

C++中的动态多维数组

图文推荐
HDOJ 4691 Front compression 后缀数组
ZOJ 3640 Help Me
HDOJ 4691 Front compression 后缀数组
CF 518C(Anya and
HDOJ 4691 Front compression 后缀数组
hdu 1016 Prime R
UVA - 11987 - A

分类:默认分类 时间:2012-01-03 人气:10
本文关键词:
分享到:

相关文章

  • HDOJ 1813 Escape from Tetris 2012-01-28

    IDA*搜索。。。 Escape from Tetris Time Limit: 12000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 730 Accepted Submission(s): 162 Problem Description 由于整日整夜地对着这个棋盘,Lele终于走火入魔。每天一睡觉,他就会梦到自己会被人被扔进一个棋盘中,一直找不到出路,然后从梦中惊醒。

  • HDOJ 5071 Chat 模拟 2013-04-20

    大模拟: 1》saygoodbye要先对 always on top 的人说 2》对没有说过话的不要说good bye 3》用long long Chat Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 337 Accepted Submission(s): 82 Problem Description As everyone knows

  • HDOJ 3478 Catch 2013-09-16

    二分图染色。。。。 Catch Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1214 Accepted Submission(s): 579 Problem Description A thief is running away! We can consider the city where he locates as an undire

  • HDOJ 4604 Deque 2013-11-20

    Deque Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2054 Accepted Submission(s): 746 Problem Description Today, the teacher gave Alice extra homework for the girl weren't attentive in his class.

  • HDOJ 4612 Warm up 2014-11-29

    缩点+树的直径+扩栈 Warm up Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 3140 Accepted Submission(s): 715 Problem Description   N planets are connected by M bidirectional channels that allow instant tr

  • HDOJ 4696 Answers 乱搞 2012-01-07

    乱搞: rt,有1就能输出所有的数,否则只能输出偶数 Answers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 489 Accepted Submission(s): 294 Problem Description Sample Input 2 4 2 2 2 1 0 1 2 3 Sample Output NO YES YES Y

  • HDOJ 4430 Yukari's Birthday 2012-01-16

    C++高精度问题太蛋疼了.... Yukari's Birthday Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2891 Accepted Submission(s): 604 Problem Description Today is Yukari's n-th birthday. Ran and Chen hold a celebr

  • HDOJ 题目2102 A计划(BFS) 2012-01-30

    A计划 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 10858 Accepted Submission(s): 2646 Problem Description 可怜的公主在一次次被魔王掳走一次次被骑士们救回来之后,而今,不幸的她再一次面临生命的考验。魔王已经发出消息说将在T时刻吃掉公主,因为他听信谣言说吃公主的肉也能长生不老。年迈的国王

  • HDOJ 5001 Walk 2012-03-05

    姒???DP dp[j][d] 琛ㄧず涓?缁?杩?i?硅蛋d姝ュ????姒??? dp[j][d]=sigma ( dp[k][d-1] * Probability ) ans = sigma ( dp[j][D] ) Walk Time Limit: 30000/15000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 401 Accepted Submission(s): 261

Copyright (C) quwantang.com, All Rights Reserved.

趣玩堂 版权所有 京ICP备15002868号

processed in 0.054 (s). 10 q(s)