/*
Splits a given string into Ababa or ababcab!
Idea: brute-force enumeration of A, B, and C strings!
*/
1 # include <iostream> 2 # include <cstring> 3 # include <cstdio> 4 # include <string> 5 6 using namespace STD; 7 string STR; 8 char ch [55]; 9 int main () {10 int t; 11 scanf ("% d", & T); 12 getchar (); 13 while (t --) {14 char cc; 15 int CNT = 0; 16 scanf ("% C", & CC); 17 18 while (CC! = '\ N ') {19 if (CC> = 'A' & CC <= 'Z' | CC> = 'A' & CC <= 'Z ')) 20 CH [CNT ++] = cc; 21 scanf ("% C", & CC); 22} 23 ch [CNT] = '\ 0 '; 24 STR = string (CH); 25 int Len = strlen (CH); 26 bool flag = false; 27 for (INT I = 1; I <Len/2; ++ I) {28 string a = Str. substr (0, I); 29 for (Int J = 1; j <Len/2; ++ J) {30 if (I + j> Len/2) break; 31 string B = Str. substr (0 + I, j); 32 if (a = B) continue; 33 int LL = I; 34 int K = I + J, X; 35 36 for (x = 0; x <ll & K <Len; ++ K, ++ X) 37 if (a [x]! = CH [k]) 38 break; 39 if (x = ll) {40 k = I + J + I; 41 LL = J; 42 for (x = 0; x <ll & K <Len; ++ K, ++ X) 43 If (B [x]! = CH [k]) 44 break; 45 if (x = ll) {46 47 LL = I; 48 k = I + J + I + J; 49 for (x = 0; x <ll & K <Len; ++ K, ++ X) 50 if (a [x]! = CH [k]) 51 break; 52 If (x = ll & K = Len) 53 flag = true; 54 if (! Flag) {55 K = I + J + I + J; 56 LL = J; 57 int M = len-1; 58 for (x = ll-1; x> = 0 & M> K; -- M, -- X) 59 If (B [x]! = CH [m]) 60 break; 61 If (x =-1) {62 LL = I; 63 for (x = ll-1; x> = 0 & M> K; -- M, -- X) 64 if (a [x]! = CH [m]) 65 break; 66 If (x =-1) {67 string c = Str. substr (K, M-k + 1); 68 if (! = C & B! = C) 69 flag = true; 70} 71} 72} 73} 74} 75} 76} 77 If (FLAG) printf ("Yes \ n "); 78 else printf ("NO \ n"); 79} 80 return 0; 81}
2014 select zojpretty poem (brute force enumeration)