P10920 0分#暴力#求助
  • 板块题目总版
  • 楼主Danielhaohao
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/8/28 21:09
  • 上次更新2024/8/29 00:40:17
查看原帖
P10920 0分#暴力#求助
1273525
Danielhaohao楼主2024/8/28 21:09
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t;
	cin>>t;
	for(int len=1;len<=t;len++){
		int n;
		string s;
		cin>>n>>s;
		int ans=0;
		for(int i=n;i>=2;i--){
			for(int j=0;j+i-1<n;j++){
				int l=j,r=j+i-1;
				bool flag=true;
				while(l<=r){
					if(s[l]!=s[r]){
						if(s[l]!='?'&&s[r]!='?'){
							flag=false;
							break;
						}
					}
					l++;
					r--;
			    }
				if(flag==true){
					ans=i;
					break;
				}
			}
			if(ans>0){
				cout<<ans/2<<"\n";
				break;
			}
		}
		//cout<<mx<<endl;
	}
	return 0;
} 
2024/8/28 21:09
加载中...