Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.3 kB
5
Indexable
Never
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class CopyOfSolution2 {
	static{
		try {
			System.setIn(new FileInputStream("src/inp.txt"));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	static int getlen(char[] inp){
		int n=inp.length;
		for(int len=n;len>=1;--len)
			for(int i=0;i<=n-len;++i){
				int len2=len>>1;
				boolean chk=true;
				for(int j=0;j<len2;++j)
					if(inp[i+j]!=inp[i+len-j-1]){
						chk=false;
						break;
					}
				if(chk)
					return len;
			}
		return 0;
	}
	
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		
		while(scanner.hasNext()){
			int t=Integer.parseInt(scanner.next());
			char[][] mat=new char[100][100];
			
			for(int i=0;i<100;++i){
				char[] tmp=scanner.next().toCharArray();
				for(int j=0;j<100;++j)
					mat[i][j]=tmp[j];
			}
				
			int len=0;
			for(int i=0;i<100;++i)
				len=Math.max(len,getlen(mat[i]));
			
			for(int i=0;i<100;++i){
				char tmp[]=new char[100];
				for(int j=0;j<100;++j)
					tmp[j]=mat[j][i];
				len=Math.max(len,getlen(tmp));
			}
			
			System.out.printf("#%d %d\n",t,len);
		}
		
		scanner.close();
	}
}