#P16600. [SYSUCPC 2025] Perfect Life

    ID: 16369 Type: RemoteJudge 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 8 Uploaded By: Tags>动态规划 DP2025动态规划优化位运算高校校赛

[SYSUCPC 2025] Perfect Life

题目描述

Dr.Z\texttt{Dr.Z} wants to live a perfect life. In the future, he acquires a time machine that gives him a chance to alter his life. His life is represented by a string SS. He can modify the string SS using another string TT.

Each modification allows him to choose a positive integer ii in the range [1,ST+1][1, |S| - |T| + 1] and replace the substring S[i:i+T1]S[i : i + |T| - 1] with TT. More precisely, for each j[1,T]j \in [1, |T|], he sets Si+j1=TjS_{i+j-1} = T_j. This operation can be performed infinitely many times.Dr.Z\texttt{Dr.Z} considers his life perfect if and only if i[1,S],Si=SSi+1\forall i \in [1, |S|], S_i = S_{|S| - i + 1}---that is, when the string SS becomes a palindrome.

Dr.Z\texttt{Dr.Z} wants to know whether it's possible for his life to become perfect through these modifications.

There are tt test cases. For each test case, you are given two strings SS and TT.If SS can become a palindrome, output Yes\texttt{Yes}. Otherwise, output No\texttt{No}.

输入格式

The first line contains an integer tt means that there are tt test cases.

The next tt lines each contain 22 strings S,T (1S106,T60)S,T\ (1\le |S|\le 10^6,|T|\le 60).

It is guaranteed that SS and TT contain only uppercase and lowercase letters, and the total length of all strings SS across test cases does not exceed 2×1062\times 10^6.

输出格式

The next tt lines each contain Yes\texttt{Yes} or No\texttt{No}.

9
asdppsaAA Aad
pjdaAjcKaA Aad
pjdsdAadaA Aad
pjdjAjcKsA Aad
ABAB AB
BBA AB
abcdDea cd
abcdDea cb
asbAADbbaaa abbc
Yes
Yes
Yes
No
No
Yes
No
Yes
Yes

提示

In the first test case, SS can be turned into a palindrome through 3 modifications. By sequentially choosing i=1,4,2i = 1, 4, 2, SS is changed as follows: $S \to \text{AadppsaAA}\to \text{AadAadaAA}\to \text{AAadadaAA}$.

In the fourth test case,there is no way to change.