a833: Cyclic Shifts
Tags :
Accepted rate : 19人/19人 ( 100% ) [非即時]
評分方式:
Strictly

最近更新 : 2022-10-16 19:20

Content

Thuc likes finding cyclic shifts of strings. A cyclic shift of a string is obtained by moving characters from the beginning of the string to the end of the string. We also consider a string to be a cyclic shift of itself. For example, the cyclic shifts of ABCDE are:

ABCDE, BCDEA, CDEAB, DEABC, and EABCD.

Given some text, T, and a string, S, determine if T contains a cyclic shift of S.

Input

The input will consist of exactly two lines containing only uppercase letters. The first line will be the text T, and the second line will be the string S. Each line will contain at most 1000 characters.

Output

Output yes if the text, T, contains a cyclic shift of the string, S. Otherwise, output no.

Sample Input #1
ABCCDEABAA
ABCDE
Sample Output #1
yes
Sample Input #2
ABCDDEBCAB
ABA
Sample Output #2
no
測資資訊:
記憶體限制: 64 MB
公開 測資點#0 (3%): 1.0s , <1K
公開 測資點#1 (3%): 0.3448275862068966s , <1K
公開 測資點#2 (3%): 0.3448275862068966s , <1K
公開 測資點#3 (3%): 0.3448275862068966s , <1K
公開 測資點#4 (3%): 0.3448275862068966s , <1K
公開 測資點#5 (3%): 0.3448275862068966s , <1K
公開 測資點#6 (3%): 0.3448275862068966s , <1K
公開 測資點#7 (3%): 0.3448275862068966s , <1K
公開 測資點#8 (3%): 0.3448275862068966s , <1K
公開 測資點#9 (3%): 0.3448275862068966s , <1K
公開 測資點#10 (3%): 0.3448275862068966s , <1K
公開 測資點#11 (3%): 0.3448275862068966s , <1K
公開 測資點#12 (3%): 0.3448275862068966s , <1K
公開 測資點#13 (3%): 0.3448275862068966s , <1K
公開 測資點#14 (3%): 0.3448275862068966s , <1K
公開 測資點#15 (3%): 0.3448275862068966s , <1M
公開 測資點#16 (4%): 0.3448275862068966s , <1M
公開 測資點#17 (4%): 0.3448275862068966s , <1K
公開 測資點#18 (4%): 0.3448275862068966s , <1K
公開 測資點#19 (4%): 0.3448275862068966s , <1M
公開 測資點#20 (4%): 0.3448275862068966s , <1M
公開 測資點#21 (4%): 0.3448275862068966s , <1K
公開 測資點#22 (4%): 0.3448275862068966s , <1K
公開 測資點#23 (4%): 0.3448275862068966s , <1M
公開 測資點#24 (4%): 0.3448275862068966s , <1M
公開 測資點#25 (4%): 0.3448275862068966s , <1M
公開 測資點#26 (4%): 0.3448275862068966s , <1M
公開 測資點#27 (4%): 0.3448275862068966s , <1M
公開 測資點#28 (4%): 0.3448275862068966s , <1M
Hint :

For sample 2:

The cyclic shifts of ABA are ABA, BAA, and AAB. None of these shifts are contained in the text ABCDDEBCAB.

Tags:
出處:
[管理者:
cplei@g.puic... (李振邦Lei Chan Pon...)
]


ID User Problem Subject Hit Post Date
沒有發現任何「解題報告」