import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
String s = sc.next();
int ans = 0;
for (int i = s.length() / 2; i >= 1; i--) {
int c = 0;
for (int j = 0; j + i < s.length(); j++) {
if (s.charAt(j) == s.charAt(j + i) || s.charAt(j) == '?' || s.charAt(j + i) == '?') {
c++;
} else {
c = 0;//间隔距离为i,永远是相同的两个数匹配在一起
}
if (c == i) {
ans = Math.max(ans, c);
break;
}
}
if (c == i) {
break;
}
}
System.out.println(ans * 2);
}
}
}
codeforces-D
最新推荐文章于 2024-11-03 21:27:26 发布