#include#include #include #include #include
if(rt < lt ) break;
else if (ch[rt] != ch[lt]) { cur = 0; break; }if(rt < lt || ch[rt] != ch[lt]) break; cur += 2; } ans = max(ans,cur); } } cout << ans;}*//*最初想到的办法,分治,我觉得算法复杂度应该是nlgn,但实际运行起来很慢int test(int i, int flag) { int temp = -1, j, ans=-1e9; if(flag == 1) { temp = 1; j = 1; while((i-j>=0) && (i+j=0) && (i+j-1 =0) && (i+j j) return 0; if(i == j) return 1; int mid = (i+j)/2; int ans = max(traverse(i,mid), traverse(i+1,j)); int p = max(test(mid,0),test(mid,1)); return max(ans,p);}int main() { FILE *fp = fopen("1.txt","r"); fgets(ch, 2000, fp); len = strlen(ch) ; cout << traverse(0, len-1);}*/