POJ 1743 Musical Theme (Hash)】的更多相关文章

Musical Theme Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 33820   Accepted: 11259 Description A musical melody is represented as a sequence of N (1<=N<=20000)notes that are integers in the range 1..88, each representing a key on the…
标题效果:有一个美丽的旋律,它们是由一些不大于88音调.如果计为五个音调的量度,问:是否有相同的节奏的多个部分(相同的差,以及两者之间的相同的节奏不能重叠),并寻求最长长度. 思考:这个问题是八人中的问题,正解是自己主动机后缀,但我不会. 但是某神犇说过:"Hash大法好". 于是这个题Hash+二分也能够解决.分析时间复杂度.2w个点,二分logn.hash挂链推断O(kn),总复杂度O(knlogn).解决. 将原数组两两做差,然后依照这个数组hash. 二分枚举最长的同样的韵律长…
永恒的大牛,kuangbin,膜拜一下,Orz 链接:http://www.cnblogs.com/kuangbin/archive/2013/04/23/3039313.html Musical Theme Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 14334   Accepted: 4945 Description A musical melody is represented as a sequence of…
poj 1743 Musical Theme(最长重复子串 后缀数组) 有N(1 <= N <=20000)个音符的序列来表示一首乐曲,每个音符都是1..88范围内的整数,现在要找一个重复的主题."主题"是整个音符序列的一个子串,它需要满足如下条件:1.长度至少为5个音符.2.在乐曲中重复出现(可能经过转调,"转调"的意思是主题序列中每个音符都被加上或减去了同一个整数值).3.重复出现的同一主题不能有公共部分. 首先把序列差分一下,那么现在,问题就转换成…
题目链接: Poj  1743 Musical Theme 题目描述: 给出一串数字(数字区间在[1,88]),要在这串数字中找出一个主题,满足: 1:主题长度大于等于5. 2:主题在文本串中重复出现(或者经过调转出现,调转是主题同时加上或者减去同一个整数) 3:重复主题不能重叠 解题思路: 求调转重复出现的子串,那么主题之间的差值一定是不变的.可以求文本串s中相邻两个数的差值,重新组成一个新的文本串S,然后找S后缀串中最长公共不重叠前缀.rank相邻的后缀串,公共前缀一定最长,但是有可能重叠.…
题目冲鸭:http://poj.org/problem?id=1743 Musical Theme Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 36590   Accepted: 12087 Description A musical melody is represented as a sequence of N (1<=N<=20000)notes that are integers in the range 1…
Musical Theme Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 15900   Accepted: 5494 Description A musical melody is represented as a sequence of N (1<=N<=20000)notes that are integers in the range 1..88, each representing a key on the…
Musical Theme 题意 给出n个1-88组成的音符,让找出一个最长的连续子序列,满足以下条件: 长度大于5 不重叠的出现两次(这里的出现可以经过变调,即这个序列的每个数字全都加上一个整数x) 思路 我们处理一下这个所谓的"变调":令\(a[i]=a[i+1]-a[i]\),这样就转化成了找最长的出现至少两次的不重叠子串.(这时长度变为n-1) 两种做法:1.二分+ hash 2. 二分+后缀数组 使用hash的时候,对于当前二分的长度x. 我们从x开始遍历到n,如果[i-x+…
Musical ThemeTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://poj.org/problem?id=1743 Description A musical melody is represented as a sequence of N (1<=N<=20000)notes that are integers in the range 1..88, each representing a key on the piano. It…
Musical Theme Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 16162   Accepted: 5577 Description A musical melody is represented as a sequence of N (1<=N<=20000)notes that are integers in the range 1..88, each representing a key on the…