c035: ii.歌詞搜尋$(Chorus)$
Tags : 字串
Accepted rate : 1人/2人 ( 50% ) [非即時]
評分方式:
Tolerant

最近更新 : 2021-01-07 22:27

Content

我們在聽歌的時候,通常最令人難忘,最琅琅上口的部分就是副歌(Chorus)了,請你寫一個程式找出一首歌中的副歌部分。

 

副歌通常會重複,不過當然有一些句子也會重複,所以我們可以用以下標準找出副歌:重複出現過的最長連續句子。

 

以Jingle Bells為例:

Dashing through the snow,
In a one-horse open sleigh.
O'er the fields we go,
Laughing all the way.
Bells on bobtail ring,
Making spirits bright.
What fun it is to ride and sing,
A sleighing song tonight!
Jingle bells, jingle bells,
Jingle all the way.
Oh what fun it is to ride,
In a one-horse open sleigh!
Jingle bells, jingle bells,
Jingle all the way.
Oh what fun it is to ride,
In a one-horse open sleigh!
A day or two ago,
I thought I'd take a ride.
And soon, Miss Fanny Bright,
Was seated by my side.
The horse was lean and lank,
Misfortune seemed his lot.
He got into a drifted bank,
And then we got upsot.
Jingle bells, jingle bells,
Jingle all the way.
Oh what fun it is to ride,
In a one-horse open sleigh!
Jingle bells, jingle bells,
Jingle all the way.
Oh what fun it is to ride,
In a one-horse open sleigh!

 

在這首歌中,粗體部分便是副歌,當然"In a one-horse open sleigh."重複兩次,而副歌本身也是由重複部分組成,但是你可以發現你找不到超過八句的連續句子在這首歌裡出現超過一次,所以可以確定副歌就是這個。注意你不能把句子拆開,例如把"upsot"與"tonight"的"t"劃入副歌的部分是不可以的。還有也要注意副歌必須是連續句子。以及標點符號也在考慮範圍內喔!

 

Input

輸入一首歌。(不超過200行)

Output

輸出副歌部分。(此方法可能無法找出特定曲目的副歌,但你可以假設測資內所有曲目皆可以用上述方法找出)

Sample Input
Dashing through the snow,
In a one-horse open sleigh.
O'er the fields we go,
Laughing all the way.
Bells on bobtail ring,
Making spirits bright.
What fun it is to ride and sing,
A sleighing song tonight!
Jingle bells, jingle bells,
Jingle all the way.
Oh what fun it is to ride,
In a one-horse open sleigh!
Jingle bells, jingle bells,
Jingle all the way.
Oh what fun it is to ride,
In a one-horse open sleigh!
A day or two ago,
I thought I'd take a ride.
And soon, Miss Fanny Bright,
Was seated by my side.
The horse was lean and lank,
Misfortune seemed his lot.
He got into a drifted bank,
And then we got upsot.
Jingle bells, jingle bells,
Jingle all the way.
Oh what fun it is to ride,
In a one-horse open sleigh!
Jingle bells, jingle bells,
Jingle all the way.
Oh what fun it is to ride,
In a one-horse open sleigh!
Sample Output
Jingle bells, jingle bells,
Jingle all the way.
Oh what fun it is to ride,
In a one-horse open sleigh!
Jingle bells, jingle bells,
Jingle all the way.
Oh what fun it is to ride,
In a one-horse open sleigh!
測資資訊:
記憶體限制: 64 MB
公開 測資點#0 (10%): 1.0s , <1K
公開 測資點#1 (10%): 1.0s , <1M
公開 測資點#2 (10%): 1.0s , <1M
公開 測資點#3 (10%): 1.0s , <1K
公開 測資點#4 (10%): 1.0s , <1M
公開 測資點#5 (10%): 1.0s , <1K
公開 測資點#6 (10%): 1.0s , <1M
公開 測資點#7 (10%): 1.0s , <1M
公開 測資點#8 (10%): 1.0s , <1M
公開 測資點#9 (10%): 1.0s , <1K
Hint :
Tags:
字串
出處:
臺中一中電腦資訊研習社 [管理者:
810848 (路過)
]


ID User Problem Subject Hit Post Date
49
810848 (路過)
c035
41 2021-01-08 18:00