/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Matrix {
char data[][]; //elementos da matriz
int lin; //nr de linhas
int col; //nr de colunas
//construir matriz
Matrix(int l, int c){
data = new char[l][c];
lin = l;
col = c;
}
//ler Matriz
public void ler(Scanner in){
for(int i=0;i<lin;i++){
for(int j=0;j<col;j++){
data[i][j] = c.charAt(j);
}
}
}
private int obterMaiorAtualizado(int repeticoes, int maior){
return repeticoes > maior ? repeticoes: maior;
}
public int output(){
int maiorLinhas = 0;
int maiorColunas = 0;
for(int i = 0;i < lin;i++) {
int repeticoes = 0;
for (int j = 0; j < col; ++j) {
if (data[i][j] == '#') {
repeticoes++;
}
else {
maiorLinhas = obterMaiorAtualizado(repeticoes, maiorLinhas);
repeticoes = 0;
}
}
maiorLinhas = obterMaiorAtualizado(repeticoes, maiorLinhas);
}
for(int i = 0;i < col; i++) {
int repeticoes = 0;
for (int j = 0; j < lin; ++j) {
if (data[j][i] == '#') {
repeticoes++;
}
else {
maiorColunas = obterMaiorAtualizado(repeticoes, maiorColunas);
repeticoes = 0;
}
}
maiorColunas = obterMaiorAtualizado(repeticoes, maiorColunas);
}
return Math.
max(maiorLinhas, maiorColunas
); }
}
class Ideone
{
{
Scanner in
= new Scanner
(System.
in); int l = in.nextInt();
int c = in.nextInt();
Matrix m = new Matrix(l,c);
m.ler(in); //ler matriz
int valor = m.output();
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KCmNsYXNzIE1hdHJpeCB7CgljaGFyIGRhdGFbXVtdOyAvL2VsZW1lbnRvcyBkYSBtYXRyaXoKICAgIGludCBsaW47IC8vbnIgZGUgbGluaGFzCiAgICBpbnQgY29sOyAvL25yIGRlIGNvbHVuYXMKCiAgICAvL2NvbnN0cnVpciBtYXRyaXoKICAgIE1hdHJpeChpbnQgbCwgaW50IGMpewogICAgICAgIGRhdGEgPSBuZXcgY2hhcltsXVtjXTsKICAgICAgICBsaW4gPSBsOwogICAgICAgIGNvbCA9IGM7CiAgICB9CgogICAgLy9sZXIgTWF0cml6CgogICAgcHVibGljIHZvaWQgbGVyKFNjYW5uZXIgaW4pewogICAgICAgIGZvcihpbnQgaT0wO2k8bGluO2krKyl7CiAgICAgICAgICAgIFN0cmluZyBjID0gaW4ubmV4dCgpOwogICAgICAgICAgICBmb3IoaW50IGo9MDtqPGNvbDtqKyspewogICAgICAgICAgICAgICAgZGF0YVtpXVtqXSA9IGMuY2hhckF0KGopOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQoKICAgIHByaXZhdGUgaW50IG9idGVyTWFpb3JBdHVhbGl6YWRvKGludCByZXBldGljb2VzLCBpbnQgbWFpb3IpewogICAgICAgIHJldHVybiByZXBldGljb2VzID4gbWFpb3IgPyByZXBldGljb2VzOiBtYWlvcjsKICAgIH0KCiAgICBwdWJsaWMgaW50IG91dHB1dCgpewogICAgICAgIGludCBtYWlvckxpbmhhcyA9IDA7CiAgICAgICAgaW50IG1haW9yQ29sdW5hcyA9IDA7CgogICAgICAgIGZvcihpbnQgaSA9IDA7aSA8IGxpbjtpKyspIHsKICAgICAgICAgICAgaW50IHJlcGV0aWNvZXMgPSAwOwogICAgICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IGNvbDsgKytqKSB7CiAgICAgICAgICAgICAgICBpZiAoZGF0YVtpXVtqXSA9PSAnIycpIHsKICAgICAgICAgICAgICAgICAgICByZXBldGljb2VzKys7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICAgICAgICBtYWlvckxpbmhhcyA9IG9idGVyTWFpb3JBdHVhbGl6YWRvKHJlcGV0aWNvZXMsIG1haW9yTGluaGFzKTsKICAgICAgICAgICAgICAgICAgICByZXBldGljb2VzID0gMDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBtYWlvckxpbmhhcyA9IG9idGVyTWFpb3JBdHVhbGl6YWRvKHJlcGV0aWNvZXMsIG1haW9yTGluaGFzKTsKICAgICAgICB9CgogICAgICAgIGZvcihpbnQgaSA9IDA7aSA8IGNvbDsgaSsrKSB7CiAgICAgICAgICAgIGludCByZXBldGljb2VzID0gMDsKICAgICAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCBsaW47ICsraikgewogICAgICAgICAgICAgICAgaWYgKGRhdGFbal1baV0gPT0gJyMnKSB7CiAgICAgICAgICAgICAgICAgICAgcmVwZXRpY29lcysrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgbWFpb3JDb2x1bmFzID0gb2J0ZXJNYWlvckF0dWFsaXphZG8ocmVwZXRpY29lcywgbWFpb3JDb2x1bmFzKTsKICAgICAgICAgICAgICAgICAgICByZXBldGljb2VzID0gMDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBtYWlvckNvbHVuYXMgPSBvYnRlck1haW9yQXR1YWxpemFkbyhyZXBldGljb2VzLCBtYWlvckNvbHVuYXMpOwogICAgICAgIH0KCiAgICAgICAgcmV0dXJuIE1hdGgubWF4KG1haW9yTGluaGFzLCBtYWlvckNvbHVuYXMpOwogICAgfQoJCn0KCmNsYXNzIElkZW9uZQp7CglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbiAoU3RyaW5nW10gYXJncykgdGhyb3dzIGphdmEubGFuZy5FeGNlcHRpb24KCXsKCQlTY2FubmVyIGluID0gbmV3IFNjYW5uZXIoU3lzdGVtLmluKTsKICAgICAgICBpbnQgbCA9IGluLm5leHRJbnQoKTsKICAgICAgICBpbnQgYyA9IGluLm5leHRJbnQoKTsKICAgICAgICBNYXRyaXggbSA9IG5ldyBNYXRyaXgobCxjKTsKICAgICAgICBtLmxlcihpbik7IC8vbGVyIG1hdHJpegogICAgICAgIGludCB2YWxvciA9IG0ub3V0cHV0KCk7CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKHZhbG9yKTsKCX0KfQ==