悬赏1个关注,88pts求条
查看原帖
悬赏1个关注,88pts求条
1198296
封禁用户楼主2024/7/24 15:01
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
const int N=40005;
char c[N];
int a[N];
signed main(){
	string s,v;
	int tot=0,ans=-1,pos;
	s=" ";
	while(getline(cin,v)){
	    v+='\n';
		int n=v.size(),point=0;
		while(point<n){
			if(('a'<=v[point]&&v[point]<='z')||('A'<=v[point]&&v[point]<='Z')){
				tot+=2;
				c[tot]=tolower(v[point]);
				a[tot]=s.size();
			}
			s=s+v[point];
			++point;
		}
	}
	for(int i=3;i<tot;i+=2){
		c[i]='#';
	}c[tot+1]='*';
	c[1]='$';
	for(int i=2;i<=tot;++i){
		int r=0;
		while(c[i-r]==c[i+r]){
			++r;
		}
		--r;
		if(!('a'<=c[i]&&c[i]<='z')) ++r;
		r/=2;
		if(c[i]=='#') r*=2;
		else r=2*r+1;
		if(r>ans){
			ans=r;
			pos=i;
		}
	}cout<<ans<<endl;
	if(c[pos]=='#') --pos;
	pos-=2*(ans/2);
	pos=a[pos];
	int cnt=0;
	while(cnt<ans){
		if(('a'<=s[pos]&&s[pos]<='z')||('A'<=s[pos]&&s[pos]<='Z')) ++cnt;
		cout<<s[pos];
		++pos;
	}
	return 0;
}
2024/7/24 15:01
加载中...