- 1、本文档共7页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Pku1743 Musical Theme详细解题报告后缀数组求不重叠的最长重复子串
Pku1743 Musical Theme
/*
Name: pku1743
Copyright: ecjtu_acm
Author: yimao
Date: 16/02/11 13:35
Description: 二分答案,
后缀数组求不重叠的最长重复子串
*/
一、题目
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 is unfortunate but true that this representation of melodies ignores the notion of musical timing; but, this programming task is about notes and not timings. Many composers structure their music around a repeating qout;themeqout;, which, being a subsequence of an entire melody, is a sequence of integers in our representation. A subsequence of a melody is a theme if it:
is at least five notes long
appears (potentially transposed -- see below) again somewhere else in the piece of music
is disjoint from (i.e., non-overlapping with) at least one of its other appearance(s)
Transposed means that a constant positive or negative value is added to every note value in the theme subsequence. Given a melody, compute the length (number of notes) of the longest theme. One second time limit for this problems solutions!
Input
The input contains several test cases. The first line of each test case contains the integer N. The following n integers represent the sequence of notes. The last test case is followed by one zero.
Output
For each test case, the output file should contain a single line with a single integer that represents the length of the longest theme. If there are no themes, output 0.
Sample Input
30
25 27 30 34 39 45 52 60 69 79 69 60 52 45 39 34 30 26 22 18
82 78 74 70 66 67 64 60 65 80
0
Sample Output
5
Hint
Use scanf instead of cin to reduce the read time.
Source
LouTiancheng@POJ
二、题目大意及分析
【前话】
我的poj第200题;
楼教主男人八题之一;
3xian在status里以绝对的时空优势排第一;
纪念我的百度空间访问量破2000;
我的第一道后缀数组题;
典型的二分答案,用后缀数组求不重叠的最长重复子串;
网上看题解不下10篇,综合之后才知道他们大概在说些什么,感叹前人栽树,后人乘凉;
可以证明本篇文章应该是字数最多的pku1743题解了;
【题意】
给定一个正整数N(N=20000),然后是N个整数xi,(1=xi=88, 1=i=N)组成一个有序的整数序列;问这个序列中存在的最长一个符合条件的子序列长度是多少,符合的
文档评论(0)