poj2774】的更多相关文章

http://poj.org/problem?id=2774 (题目链接) 题意 给出两个只包含小写字母的字符串,求出最长连续公共子串. solution 第一次用后缀数组,感觉有点神...才发现原来sa[0]是没用的.. 将两个字符串合并为一个,并用分隔符隔开.之后跑后缀数组,求出height[],for一遍,找到在分隔符两侧的height值最大的便是答案. 代码 // poj2774 #include<algorithm> #include<iostream> #include…
题意: 求两个字符串的LCP SOL: 模板题.连一起搞一搞就好了...主要是记录一下做(sha)题(bi)过程心(cao)得(dan)体(xin)会(qing) 后缀数组概念...还算是简单的,过程也非常清晰...就是老人家...马丹代码那么写意真的是...每一句代码的意思大概都知道但是不能很准确的描述...自己实现又漏洞百出...所以虽然避免了抄模板...但还是相当于一个默写的过程... 然后这个题目...非常显然嘛不是...然后就打了...然后开始调...TLE...TLE...TLE..…
Long Long Message Description The little cat is majoring in physics in the capital of Byterland. A piece of sad news comes to him these days: his mother is getting ill. Being worried about spending so much on railway tickets (Byterland is such a big…
[POJ2774]Long Long Message(后缀数组) 题面 Vjudge Description Little cat在Byterland的首都读物理专业.这些天他收到了一条悲伤地信息:他的母亲生病了.担心买火车票花钱太多(Byterland是一个巨大的国家,因此他坐火车回家需要16小时),他决定只给母亲发短信. Little cat的家境并不富裕,因此他经常去营业厅查看自己发短信花了多少钱.昨天营业厅的电脑坏掉了,打印出两条很长的信息.机智的little cat很快发现: 1.信息…
题面 HiHocoder1415 Poj2774 Sol 都是求最长公共子串,\(hihocoder\)上讲的很清楚 把两个串拼在一起,中间用一个特殊字符隔开 那么答案就是排序后相邻两个不同串的后缀的\(height\) 为什么呢? 如果答案为不相邻的两个后缀的前缀,计算它们最长前缀时必定要跨越过这些中间\(height\)值,也就是选相邻的两个一定要比不选相邻的两个更优 # include <bits/stdc++.h> # define IL inline # define RG regi…
cogs1713 [POJ2774]很长的信息 原题链接 题解 把两串拼成A+'%'+B+'$'.跑后缀数组然后相邻两点i,i+1不在同一串里就用ht[i]更新答案. 好裸... Code // It is made by XZZ #include<cstdio> #include<algorithm> #include<cstring> #define Fname "lcs" using namespace std; #define rep(a,b…
Long Long Message Description The little cat is majoring in physics in the capital of Byterland. A piece of sad news comes to him these days: his mother is getting ill. Being worried about spending so much on railway tickets (Byterland is such a big…
poj2774 题意 求两个字符串的最长公共子串 分析 论文 将两个字符串合并,中间插入分隔符,在找最大的 height 值的时候保证,两个字符串后缀的起始点分别来自原来的两个字符串. code #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int MAXN = 2e5 + 10; char s[MAXN], s2[MAXN]; int sa[MAXN]…
题目链接:https://vjudge.net/problem/POJ-2774 Long Long Message Time Limit: 4000MS   Memory Limit: 131072K Total Submissions: 33144   Accepted: 13344 Case Time Limit: 1000MS Description The little cat is majoring in physics in the capital of Byterland. A…
题意:求两个字符串的最长公共子串 n<=1000 思路:这是一道论文题 ..]of longint; n,l1,l2,i,ans,m,l,r:longint; ch:ansistring; procedure swap(var x,y:longint); var t:longint; begin t:=x; x:=y; y:=t; end; function max(x,y:longint):longint; begin if x>y then exit(x); exit(y); end; f…