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

15100번 - Orderly Class 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB43252569.444%

문제

Ms. Thomas is managing her class of n students.

She placed all her students in a line, and gave the i-th student from the left a card with the letter ai written on it.

She would now like to rearrange the students so that the i-th student from the left has a card with the letter bi written on it.

To do this, she will choose some consecutive group of students, and reverse their order. Students will hold on to their original cards during this process.

She’s now wondering, what is the number of valid ways to do this? (It may be impossible, in which case, the answer is zero). With sequences abba and aabb, Ms. Thomas can choose the group a(bba).

With sequences caxcab and cacxab, Ms. Thomas can choose ca(xc)ab or c(axca)b. With sequences a and z, there are clearly no solutions.

입력

The input is two lines of lowercase letters, A and B. The i-th character of A and B represent ai and bi respectively. It is guaranteed that A and B have the same positive length, and A and B are not identical. The common length is allowed to be as large as 100 000.

출력

For each test case, output a single integer, the number of ways Ms. Thomas can reverse some consecutive group of A to form the line specified by string B.

제한

예제 입력 1

abba
aabb

예제 출력 1

1

예제 입력 2

caxcab
cacxab

예제 출력 2

2

예제 입력 3

a
z

예제 출력 3

0

힌트

출처

ICPC > Regionals > North America > Mid-Central Regional > 2017 Mid-Central Regional Programming Contest F번

ICPC > Regionals > North America > South Central USA Regional > 2017 South Central USA Regional Programming Contest H번

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

출처

대학교 대회

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

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