Problem Description:
Can we divided a given string S into three nonempty palindromes?
Input:
First line contains a single integer T≤20 which denotes the number of test cases.
For each test case , there is an single line contains a string S which only consist of lowercase English letters.1≤|s|≤20000
For each test case , there is an single line contains a string S which only consist of lowercase English letters.1≤|s|≤20000
Output:
For each case, output the "Yes" or "No" in a single line.
Sample Input:
2
abc
abaadada
Sample Output:
Yes
No
题意:判断一个字符串是否能完全分成三个回文串。
分析:一个字符串如果想要分成三个字符串,那么肯定第一个回文串的左端点肯定是第一个字符,第三个回文串的右端点肯定是最后一个字符,那么我们只需要判断中间的字符串是否是回文串就行啦。
#include<stdio.h> #include<string.h> #include<queue> #include<math.h> #include<stdlib.h> #include<algorithm> using namespace std; const int N=1e6+10; const int INF=0x3f3f3f3f; const int MOD=1e9+7; typedef long long LL; char s[N], str[N]; int r[N], k, left[N], right[N], L, R; void Palind() { int i, index = 0; for (i = 2; str[i] != '