Logo
(追記) (追記ここまで)

11852번 - Round words 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 128 MB74222819136.381%

문제

After the recent apocalypse, Azamat, finally, learned about the largest common subsequences of two strings and now he is interested, what will be the largest common subsequence of two round words?

In a round word there is no difference from which symbol the word starts and in which direction it is read.

For instance, the round word "algorithm" can be read as "rithmalgo" and as "oglamhtir".

For usual words "algorithm" and "grammar" the longest common subsequence length is 3 (the word "grm"), and for round variant of the same word the length of the longest common subsequence is 4 (the word "grma").

Azamat quickly found out that the standard algorithm cannot get right answer for round words. Write the program which will do that for him.

입력

Two lines contain one word each. Words are non-empty and the length of each words doesn't exceed 2000 characters.

출력

The single line must contain one integer number - the length of the longest common subsequence of the given round words.

제한

예제 입력 1

algorithm
grammar

예제 출력 1

4

힌트

출처

Olympiad > International Zhautykov Olympiad > IZhO 2013 G번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /