#P17330. [ICPC 2018 Nanjing R] Mediocre String Problem

    ID: 19672 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度提高+/省选− 上传者: 标签>字符串2018二分哈希 hashingManacher 算法ICPC南京Z 函数

[ICPC 2018 Nanjing R] Mediocre String Problem

Problem Description

Given two strings ss and tt, count the number of tuples (i,j,k)(i, j, k) such that

  1. 1ijs1 \le i \le j \le |s|
  2. 1kt1 \le k \le |t|.
  3. ji+1>kj - i + 1 > k.
  4. The ii-th character of ss to the jj-th character of ss, concatenated with the first character of tt to the kk-th character of tt, is a palindrome.

A palindrome is a string which reads the same backward as forward, such as "abcba\texttt{abcba}" or "xyzzyx\texttt{xyzzyx}".

Input Format

The first line is the string ss (2s1062 \le |s| \le 10^6).

The second line is the string tt (1t<s1 \le |t| < |s|).

Both ss and tt contain only lower case Latin letters.

Output Format

The number of such tuples.

ababa
aba
5
aabbaa
aabb
7