You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
1.6 KiB

///*
// * algorithm06.cpp
// *
// * Created on: Jun 2, 2024
// * Author: 28032
// */
//
//#include <iostream>
//#include <string>
//#include <vector>
//#include <algorithm>
//
//using namespace std;
//
////1.
////bool iscy(string t)
////{
//// string p = t;
//// reverse(t.begin(),t.end());
//// return t == p;
////}
//
////3.
//int findMaxD(string s,int low,int high)
//{
// while(low>=0 && high< (int)s.length() && s[low] == s[high])
// {
// low--;
// high++;
// }
//
// return high-low-1;
//}
//
//int main()
//{
// int T;
// cin>>T;
// while(T--)
// {
// string ss;
// cin>>ss;
// int n = ss.length();
// int be = 0,ml = 1;
// //2.
//// vector<vector<bool> > dp(n+5,vector<bool> (n+5,false));
//// for(int i = 0;i < n;i++)
//// dp[i][i] = true;
////
//// for(int j = 0;j < n;j++)
//// {
//// for(int i = 1;i < n && i<j;i++)
//// {
//// if(ss[i] == ss[j])
//// {
//// if(j-i <=2)
//// dp[i][j] = true;
//// else
//// dp[i][j] = dp[i+1][j-1];
//// }
//// if(dp[i][j] && j-i+1>ml)
//// {
//// be = i;
//// ml = j-i+1;
//// }
//// }
//// }
//
// //1.
//// for(int i = 0;i < n;i++)
//// {
//// for(int j = i;j < n;j++)
//// {
//// if(iscy(ss.substr(i,j-i+1)))
//// {
//// if(j-i+1>ml)
//// {
//// be = i;
//// ml = j-i+1;
//// }
//// }
//// }
//// }
//
// for(int i = 0;i < n;i++)
// {
// int d = max(findMaxD(ss,i,i),findMaxD(ss,i,i+1));
// if(d > ml)
// {
// be = i-d/2;
// if(d%2 == 0) be++;
// ml = d;
// }
// }
//
// cout<<be<<" "<<ml<<endl;
// }
//
//
//
// return 0;
//}
//
//
//