/* ID:chenjiong PROG:calfflac LANG:C++ */ #include <stdio.h> #include <string.h> #include <iostream> using namespace std; char txt[20005]; int len; typedef struct { int l; int r; int mid; int length; }NODE; NODE final; NODE tmp; bool is_same(char a,char b) { if ( a == b || a - b == 'A' - 'a' || b - a == 'A' - 'a' ) return true; return false; } void find_odd(int cur,NODE& t) { if ( !isalpha(txt[cur]) ) return; t.mid = cur; t.length = 1; t.l = t.r = cur; int i = cur - 1; int j = cur + 1; while ( i >= 0 && j <= len - 1 ) { if ( !isalpha(txt[i]) ) { i--; continue; } if ( !isalpha(txt[j]) ) { j++; continue; } if ( !is_same(txt[i],txt[j]) ) return; t.l = i--; t.r = j++; t.length += 2; } } void find_even(int cur,NODE& t) { if ( !isalpha(txt[cur]) ) return; int i = cur; int j = cur + 1; while ( j <= len - 1 ) { if ( !isalpha(txt[j]) ) j++; else break; } if ( !is_same(txt[i],txt[j]) ) return; t.l = i; t.r = j; t.length = 2; t.mid = cur; i--; j++; while ( i >= 0 && j <= len - 1 ) { if ( !isalpha(txt[i]) ) { i--; continue; } if ( !isalpha(txt[j]) ) { j++; continue; } if ( !is_same(txt[i],txt[j]) ) return; t.l = i--; t.r = j++; t.length += 2; } } int main() { freopen("calfflac.in","r",stdin); freopen("calfflac.out","w",stdout); cin.getline(txt,20000,'\0'); len = strlen(txt); // printf("%s\n",txt); int i; for ( i = 0; i < len; i++) { find_even(i,tmp); if ( tmp.length > final.length ) final = tmp; find_odd(i,tmp); if ( tmp.length > final.length ) final = tmp; } txt[final.r + 1] = '\0'; printf("%d\n",final.length); printf("%s\n",&txt[final.l]); return 0; }