Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include <map>#include <set>#include <queue>#include <stack>#include <math.h>#include <time.h>#include <stdio.h>#include <stdlib.h>#include <iostream>#include <limits.h>#include <string.h>#include <string>#include <algorithm>#include <iomanip>#define Min(a,b) (((a) < (b)) ? (a) : (b))#define Max(a,b) (((a) > (b)) ? (a) : (b))#define read freopen("in.txt","r",stdin)#define write freopen("out.txt","w",stdout)using namespace std;// Transform S into T.// For example, S = "abba", T = "^#a#b#b#a#$".// ^ and $ signs are sentinels appended to each end to avoid bounds checkingstring preProcess(string s) {int n = s.length();if (n == 0) return "^$";string ret = "^";for (int i = 0; i < n; i++)ret += "#" + s.substr(i, 1);