POJ 2217 Secretary】的更多相关文章

Secretary Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged on PKU. Original ID: 221764-bit integer IO format: %lld      Java class name: Main     The basic condition of success of a political party, it is the good Election Program…
题目链接 题意:求两个字符串的最长公共子串 分析:做法是构造新的串是两个串连接而成,中间用没有出现的字符隔开(因为这样才能保证S的后缀的公共前缀不会跨出一个原有串的范围),即newS = S + '$' + T.对其求sa数组和height数组,取最小值的height[i],且两个后缀串属于不同的字符串. #include <cstdio> #include <cstring> #include <algorithm> #include <iostream>…
标题效果: 计算两个公共串串最长的字符串的长度. IDEAS: 这两个组合的字符串. 然后直接确定运行后缀数组height 然后,你可以直接扫描一次height .加个是不是在一个串中的推断就能够了. #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #define maxn 200005 using namespace std; char str[ma…
题目大意:求两个字符串的公共子串. 分析: 模板题,将两个字符串接起来用不会出现的字符分割,然后求分属两个字符串的相邻后缀lcp的最大值即可. 代码: program work; type arr=..]of longint; var sa,rank,b,tmp,lcp:arr; n,i,m,l,u,ans,t:longint; s,s1,s2:ansistring; ch:char; function compare(i,j,k:longint):longint; var ri,rj:long…
题目链接: http://poj.org/problem?id=2217 题目大意: 求两个串的最长公共子串,注意子串是连续的,而子序列可以不连续. 解题思路: 后缀数组解法是这类问题的模板解法. 对于n个串的最长公共子串,这要把这些串连在一起,中间用"$"这类的特殊符号分隔一下. 先求后缀数组,再求最长公共前缀,取相邻两个且属于不同串的sa的最大LCP即可. 原理就是:这样把分属两个串的LCP都跑了一遍,也就是相当于把所有子串走了一遍, 只不过走这些子串是经过层层预处理过的. 下面提…
Secretary Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1655   Accepted: 671 Description The basic condition of success of a political party, it is the good Election Programme. PSOS know about it, so they entrust the top secretary Juli…
Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798   Special Judge Description Every year there is the same problem at Halloween: Each neighbour is only willing to give a certain total number of sweets…
Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   Special Judge Description The input contains N natural (i.e. positive integer) numbers ( N <= 10000 ). Each of that numbers is not greater than 15000…
The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286   Accepted: 8603   Special Judge Description The game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open a…
Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Description Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the…