#include<iostream> #include<cstdio> #include<cstring> #define db(a) cout << #a << " = " << a << endl #define db2(a, b) cout << #a << " = " << a << " " << #b << " = " << b << endl #define db3(a, b, c) cout << #a << " = " << a << " " << #b << " = " << b << " " << #c << " = " << c << endl using namespace std; int main() { #ifdef dennisbot freopen("in.in", "r", stdin); freopen("ou.out", "w", stdout); #endif int test, i, j, n, matriz[100][100], fila[100], div = 1, sum = 0, max = 0; char var[100]; scanf("%d\n", &test); while (test--) { i = 0; while (gets(var) && var[0] != '\0') { n = strlen(var); for (int j = 0; j < n; j++) { matriz[i][j] = var[j] - 48; } i++; } max = 0; for (int i = 0; i < n; i++) { memset(fila, 0, sizeof fila); for (int ii = i; ii < n; ii++) { sum = 0; for (int j = 0; j < n; j++) { fila[j] += matriz[ii][j]; if (fila[j] == ii - i + 1) sum += fila[j]; else sum = 0; if (sum > max) max = sum; } } } printf("%d\n", max); if (test != 0) puts(""); } return 0; }
jueves, 15 de marzo de 2012
836 - Largest Submatrix, uva
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario