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

    ID: 16810 Type: RemoteJudge 1000ms 512MiB Tried: 0 Accepted: 0 Difficulty: 8 Uploaded By: Tags>字符串2018二分哈希 hashingManacher 算法ICPC南京Z 函数

[ICPC 2018 Nanjing R] Mediocre String Problem

题目描述

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

  1. 1≤i≤j≤∣s∣1 \le i \le j \le |s|
  2. 1≤k≤∣t∣1 \le k \le |t|.
  3. j−i+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}".

输入格式

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

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

Both ss and tt contain only lower case Latin letters.

输出格式

The number of such tuples.

ababa
aba
5
aabbaa
aabb
7