10196_MusicalThemes

2022-5-16 18:16| 发布者: Hocassian| 查看: 67| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-89504651120200-Problem List-采集的数据-后羿采集器.html

Pro.ID

10196

Title

Musical Themes

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=10196

AC

8

Submit

37

Ratio

21.62%

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    A musical melody is represented as a sequence of N (1 ≤ N ≤ 5000) 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 "theme", 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 problem's solutions!

    输入

    Multiple test cases. For each case, the first line has an integer N. Each subsequent line (except potentially the last) contains 20 integers representing the sequence of notes. The last line contains the remainder of the notes, potentially fewer than 20.

    输出

    Description

    A musical melody is represented as a sequence of N (1 ≤ N ≤ 5000) 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 "theme", 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 problem's solutions!

    Input

    Multiple test cases. For each case, the first line has an integer N. Each subsequent line (except potentially the last) contains 20 integers representing the sequence of notes. The last line contains the remainder of the notes, potentially fewer than 20.

    Output

    For each case, output 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

    Sample Output

    5

    Hint

    The five-long theme is the last five notes of the first line and the first five notes of the second.

    Source

    样例输入

    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

    样例输出

    5

    提示

    The five-long theme is the last five notes of the first line and the first five notes of the second.


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部