75pts WA on #3 and #5
查看原帖
75pts WA on #3 and #5
1231078
bjzjh楼主2025/6/18 09:17
#include<bits/stdc++.h>
using namespace std;
char s[21000],ss[21000];
int dui[21000],s_i_z_e,maxn,maxl,maxr;
char nw[21000];
bool pd(int fi,int si){
	if(fi+si>s_i_z_e) return false;
	for(int i=0;i<si/2;i++) if(nw[i+fi]!=nw[fi+si-i-1]) return false;
	return true;
}
int main(){
	while(cin.getline(s,88))
    {
        strcat(ss,s);
        strcat(ss,"\n");
    }
	for(int i=0;i<strlen(ss);i++){
		if(ss[i]>='a'&&s[i]<='z'){
			nw[s_i_z_e]=ss[i];
			dui[s_i_z_e]=i;
			s_i_z_e++;
		}
		if(ss[i]>='A'&&ss[i]<='Z'){
			nw[s_i_z_e]=ss[i]+32;
			dui[s_i_z_e]=i;
			s_i_z_e++;
		}
	}
	for(int i=0;i<s_i_z_e;i++){
		for(int j=maxn+1;j<=2000;j++){
			if(pd(i,j)){
				maxn=j;
				maxl=i;
				maxr=i+j-1; 
			}
		}
	}
	cout<<maxn<<endl;
	for(int i=dui[maxl];i<=dui[maxr];i++) cout<<ss[i];
}

2025/6/18 09:17
加载中...